comparison src/libmlk-rpg/rpg/tileset-file.c @ 348:7d7991f97acf

misc: be more barebone portable
author David Demelier <markand@malikania.fr>
date Tue, 19 Oct 2021 15:35:28 +0200
parents 8f9937403749
children 460c78706989
comparison
equal deleted inserted replaced
347:0969931b98e4 348:7d7991f97acf
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19 #include <assert.h> 19 #include <assert.h>
20 #include <errno.h> 20 #include <errno.h>
21 #include <libgen.h>
22 #include <limits.h> 21 #include <limits.h>
23 #include <stddef.h> 22 #include <stddef.h>
24 #include <stdio.h> 23 #include <stdio.h>
25 #include <stdlib.h> 24 #include <stdlib.h>
26 #include <string.h> 25 #include <string.h>
277 parse(struct context *ctx, const char *path) 276 parse(struct context *ctx, const char *path)
278 { 277 {
279 char line[1024]; 278 char line[1024];
280 char basedir[PATH_MAX]; 279 char basedir[PATH_MAX];
281 280
282 strlcpy(basedir, path, sizeof (basedir)); 281 port_strlcpy(basedir, path, sizeof (basedir));
283 strlcpy(ctx->basedir, dirname(basedir), sizeof (ctx->basedir)); 282 port_strlcpy(ctx->basedir, port_dirname(basedir), sizeof (ctx->basedir));
284 283
285 while (fgets(line, sizeof (line), ctx->fp)) { 284 while (fgets(line, sizeof (line), ctx->fp)) {
286 /* Remove \n if any */ 285 /* Remove \n if any */
287 line[strcspn(line, "\r\n")] = '\0'; 286 line[strcspn(line, "\r\n")] = '\0';
288 287