From: Shlomi Fish Date: Mon, 24 Feb 2020 19:03:47 +0000 (+0200) Subject: appveyor win10 fixes 2 - traces X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5be64376f0e4f7b407942b0d2cbd81ae85a7832d;p=fortune-mod appveyor win10 fixes 2 - traces --- diff --git a/fortune-mod/fortune/fortune.c b/fortune-mod/fortune/fortune.c index 47ca26a..d2fe398 100644 --- a/fortune-mod/fortune/fortune.c +++ b/fortune-mod/fortune/fortune.c @@ -637,9 +637,12 @@ static int add_file(int percent, register const char *file, const char *dir, ret=1; lang=p; } - if (!ret) + if (!ret) { + fprintf(stderr, "moshe\n"); perror(path); + } } else { + fprintf(stderr, "abe\n"); perror(path); } } @@ -755,6 +758,7 @@ int add_dir(register FILEDESC * fp) fp->fd = -1; if ((dir = opendir(fp->path)) == NULL) { + fprintf(stderr, "yonah\n"); perror(fp->path); return FALSE; } @@ -766,6 +770,7 @@ int add_dir(register FILEDESC * fp) names = malloc(sizeof(names[0])*max_count_names); if (! names) { + fprintf(stderr, "zach\n"); perror("Out of RAM!"); exit(-1); } @@ -780,6 +785,7 @@ int add_dir(register FILEDESC * fp) names = realloc(names, sizeof(names[0])*max_count_names); if (! names) { + fprintf(stderr, "reb\n"); perror("Out of RAM!"); exit(-1); } @@ -791,104 +797,104 @@ int add_dir(register FILEDESC * fp) for (i=0; i < count_names; ++i) { - if (add_file(NO_PROB, names[i], fp->path, &fp->child, &tailp, fp)) - { - fp->num_children++; - } - free(names[i]); + if (add_file(NO_PROB, names[i], fp->path, &fp->child, &tailp, fp)) + { + fp->num_children++; } - free(names); - dir = NULL; - if (fp->num_children == 0) + free(names[i]); +} +free(names); +dir = NULL; +if (fp->num_children == 0) +{ + /* + * Only the local fortune dir and the local offensive dir are + * allowed to be empty. + * - Brian Bassett (brianb@debian.org) 1999/07/31 + */ + if (strcmp(LOCFORTDIR, fp->path) == 0 || strcmp(LOCOFFDIR, fp->path) == 0) { - /* - * Only the local fortune dir and the local offensive dir are - * allowed to be empty. - * - Brian Bassett (brianb@debian.org) 1999/07/31 - */ - if (strcmp(LOCFORTDIR, fp->path) == 0 || strcmp(LOCOFFDIR, fp->path) == 0) - { - return TRUE; - } - fprintf(stderr, - "fortune: %s: No fortune files in directory.\n", fp->path); - return FALSE; + return TRUE; } - return TRUE; + fprintf(stderr, + "fortune: %s: No fortune files in directory.\n", fp->path); + return FALSE; +} +return TRUE; } /* - * form_file_list: - * Form the file list from the file specifications. - */ +* form_file_list: +* Form the file list from the file specifications. +*/ static int form_file_list(register char **files, register int file_cnt) { - register int i, percent; - register char *sp; - char langdir[512]; - char fullpathname[512],locpathname[512]; +register int i, percent; +register char *sp; +char langdir[512]; +char fullpathname[512],locpathname[512]; - if (file_cnt == 0) - { - if (All_forts) +if (file_cnt == 0) +{ + if (All_forts) + return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list, + &File_tail, NULL) + | add_file(NO_PROB, LOCOFFDIR, NULL, &File_list, + &File_tail, NULL) + | add_file(NO_PROB, FORTDIR, NULL, &File_list, + &File_tail, NULL) + | add_file(NO_PROB, OFFDIR, NULL, &File_list, + &File_tail, NULL)); + else if (Offend) + return (add_file(NO_PROB, LOCOFFDIR, NULL, &File_list, + &File_tail, NULL) + | add_file(NO_PROB, OFFDIR, NULL, &File_list, + &File_tail, NULL)); + else { + if (env_lang) { + char *lang; + char llang[512]; + int ret=0; + char *p; + + strncpy(llang,env_lang,sizeof(llang)); + llang[sizeof(llang)-1] = '\0'; + lang=llang; + + /* the language string can be like "es:fr_BE:ga" */ + while ( lang && (*lang)) { + p=strchr(lang,':'); + if (p) *p++='\0'; + + /* first try full locale */ + ret=add_file(NO_PROB, lang, NULL, &File_list, + &File_tail, NULL); + + /* if not try language name only (two first chars) */ + if (!ret) { + char ll[3]; + + strncpy(ll,lang,2); + ll[2]='\0'; + ret=add_file(NO_PROB, ll, NULL, + &File_list, &File_tail, NULL); + } + + /* if we have found one we have finished */ + if (ret) + return ret; + lang=p; + } + /* default */ return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list, &File_tail, NULL) - | add_file(NO_PROB, LOCOFFDIR, NULL, &File_list, - &File_tail, NULL) | add_file(NO_PROB, FORTDIR, NULL, &File_list, - &File_tail, NULL) - | add_file(NO_PROB, OFFDIR, NULL, &File_list, - &File_tail, NULL)); - else if (Offend) - return (add_file(NO_PROB, LOCOFFDIR, NULL, &File_list, - &File_tail, NULL) - | add_file(NO_PROB, OFFDIR, NULL, &File_list, &File_tail, NULL)); - else { - if (env_lang) { - char *lang; - char llang[512]; - int ret=0; - char *p; - - strncpy(llang,env_lang,sizeof(llang)); - llang[sizeof(llang)-1] = '\0'; - lang=llang; - - /* the language string can be like "es:fr_BE:ga" */ - while ( lang && (*lang)) { - p=strchr(lang,':'); - if (p) *p++='\0'; - - /* first try full locale */ - ret=add_file(NO_PROB, lang, NULL, &File_list, - &File_tail, NULL); - - /* if not try language name only (two first chars) */ - if (!ret) { - char ll[3]; - - strncpy(ll,lang,2); - ll[2]='\0'; - ret=add_file(NO_PROB, ll, NULL, - &File_list, &File_tail, NULL); - } - - /* if we have found one we have finished */ - if (ret) - return ret; - lang=p; - } - /* default */ - return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list, - &File_tail, NULL) - | add_file(NO_PROB, FORTDIR, NULL, &File_list, - &File_tail, NULL)); - } - else - /* no locales available, use default */ - return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list, + } + else + /* no locales available, use default */ + return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list, &File_tail, NULL) | add_file(NO_PROB, FORTDIR, NULL, &File_list, &File_tail, NULL)); @@ -1295,6 +1301,7 @@ static void get_tbl(FILEDESC * fp) #endif if ((fd = open(fp->datfile, O_RDONLY)) < 0) { + fprintf(stderr, "mir\n"); perror(fp->datfile); exit(1); } @@ -1428,6 +1435,7 @@ static void open_dat(FILEDESC * fp) { if (fp->datfd < 0 && (fp->datfd = open(fp->datfile, O_RDONLY)) < 0) { + fprintf(stderr, "goaliiii\n"); perror(fp->datfile); exit(1); } @@ -1535,6 +1543,7 @@ static void open_fp(FILEDESC * fp) { if (fp->inf == NULL && (fp->inf = fdopen(fp->fd, "r")) == NULL) { + fprintf(stderr, "tsolphhad\n"); perror(fp->path); exit(1); }