comparison src/libmlk-rpg/rpg/map-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>
224 parse(struct context *ctx, const char *path) 223 parse(struct context *ctx, const char *path)
225 { 224 {
226 char line[1024]; 225 char line[1024];
227 char basedir[PATH_MAX]; 226 char basedir[PATH_MAX];
228 227
229 strlcpy(basedir, path, sizeof (basedir)); 228 port_strlcpy(basedir, path, sizeof (basedir));
230 strlcpy(ctx->basedir, dirname(basedir), sizeof (ctx->basedir)); 229 port_strlcpy(ctx->basedir, port_dirname(basedir), sizeof (ctx->basedir));
231 230
232 while (fgets(line, sizeof (line), ctx->fp)) { 231 while (fgets(line, sizeof (line), ctx->fp)) {
233 /* Remove \n if any */ 232 /* Remove \n if any */
234 line[strcspn(line, "\r\n")] = '\0'; 233 line[strcspn(line, "\r\n")] = '\0';
235 234