HuntnGather – Diff between revs 26 and 27

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 26 Rev 27
Line 4... Line 4...
4   4  
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
-   8 #include <dirent.h>
8 #include <dirent.h> 9 #if !defined ___AmigaOS___
-   10 #include <signal.h>
Line 9... Line 11...
9 #include <signal.h> 11 #endif
10   12  
11 #include <sys/types.h> 13 #include <sys/types.h>
Line 94... Line 96...
94 const char **p = (const char **)a; 96 const char **p = (const char **)a;
95 const char **q = (const char **)b; 97 const char **q = (const char **)b;
96 #if defined ___AmigaOS___ 98 #if defined ___AmigaOS___
97 return StrnCmp(locale, (STRPTR)*p, (STRPTR)*q, -1, SC_ASCII); 99 return StrnCmp(locale, (STRPTR)*p, (STRPTR)*q, -1, SC_ASCII);
98 #else 100 #else
99 return strncmp(*p, *q, strlen(*p)); 101 return strcmp(*p, *q);
100 #endif 102 #endif
101 } 103 }
Line 102... Line 104...
102   104  
103 /* 105 /*
Line 591... Line 593...
591   593  
592 if(rem != NULL) { 594 if(rem != NULL) {
593 #if defined ___AmigaOS___ 595 #if defined ___AmigaOS___
594 if(StrnCmp(locale, lines[i], rem, -1, SC_ASCII) == 0) { 596 if(StrnCmp(locale, lines[i], rem, -1, SC_ASCII) == 0) {
595 #else 597 #else
596 if(strncmp(lines[i], rem, strlen(rem)) == 0) { 598 if(strcmp(lines[i], rem) == 0) {
597 #endif 599 #endif
598 continue; 600 continue;
599 } 601 }
Line 797... Line 799...
797 stringStack *stack; 799 stringStack *stack;
798 stats *stats; 800 stats *stats;
799 DIR *dir; 801 DIR *dir;
800 struct dirent *entry; 802 struct dirent *entry;
801 struct stat dirStat; 803 struct stat dirStat;
802 unsigned int size; -  
803 int i; 804 int i;
804 char *path; 805 char *path;
805 char *subPath; 806 char *subPath;
Line 806... Line 807...
806   807  
Line 870... Line 871...
870 if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { 871 if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) {
871 run = FALSE; 872 run = FALSE;
872 continue; 873 continue;
873 } 874 }
874 #endif 875 #endif
875 size = sizeof(path) + sizeof(entry->d_name) + 1; -  
876 switch(path[strlen(path) - 1]) { 876 switch(path[strlen(path) - 1]) {
877 case '/': 877 case '/':
878 case ':': // This is a drive path. 878 case ':': // This is a drive path.
879 if((subPath = malloc(size)) == NULL) { 879 if((subPath = malloc(sizeof(path) + sizeof(entry->d_name) + 1)) == NULL) {
880 fprintf(stderr, "Memory allocation failure.\n"); 880 fprintf(stderr, "Memory allocation failure.\n");
881 closedir(dir); 881 closedir(dir);
882 free(path); 882 free(path);
883 stringStackDestroy(stack); 883 stringStackDestroy(stack);
884 #if defined ___AsyncIO___ 884 #if defined ___AsyncIO___
Line 889... Line 889...
889 return NULL; 889 return NULL;
890 } 890 }
891 sprintf(subPath, "%s%s", path, entry->d_name); 891 sprintf(subPath, "%s%s", path, entry->d_name);
892 break; 892 break;
893 default: 893 default:
894 if((subPath = malloc(size + 1)) == NULL) { 894 if((subPath = malloc(sizeof(path) + sizeof(entry->d_name) + 1 + 1)) == NULL) {
895 fprintf(stderr, "Memory allocation failure.\n"); 895 fprintf(stderr, "Memory allocation failure.\n");
896 closedir(dir); 896 closedir(dir);
897 free(path); 897 free(path);
898 stringStackDestroy(stack); 898 stringStackDestroy(stack);
899 #if defined ___AsyncIO___ 899 #if defined ___AsyncIO___
Line 1199... Line 1199...
1199 continue; 1199 continue;
1200 } 1200 }
1201 #if defined ___AmigaOS___ 1201 #if defined ___AmigaOS___
1202 if(min == NULL || StrnCmp(locale, tmp, min, -1, SC_ASCII) < 0) { 1202 if(min == NULL || StrnCmp(locale, tmp, min, -1, SC_ASCII) < 0) {
1203 #else 1203 #else
1204 if(min == NULL || strncmp(tmp, min, strlen(tmp)) < 0) { 1204 if(min == NULL || strcmp(tmp, min) < 0) {
1205 #endif 1205 #endif
1206 if(min != NULL) { 1206 if(min != NULL) {
1207 // Free previous instance. 1207 // Free previous instance.
1208 free(min); 1208 free(min);
1209 } 1209 }
Line 1238... Line 1238...
1238 // If current minimum line is identical to previous minimum line then skip to remove duplicates. 1238 // If current minimum line is identical to previous minimum line then skip to remove duplicates.
1239 if(rem != NULL) { 1239 if(rem != NULL) {
1240 #if defined ___AmigaOS___ 1240 #if defined ___AmigaOS___
1241 if(StrnCmp(locale, min, rem, -1, SC_ASCII) == 0) { 1241 if(StrnCmp(locale, min, rem, -1, SC_ASCII) == 0) {
1242 #else 1242 #else
1243 if(strncmp(min, rem, strlen(rem)) == 0 { 1243 if(strcmp(min, rem) == 0 {
1244 #endif 1244 #endif
1245 free(min); 1245 free(min);
1246 continue; 1246 continue;
1247 } 1247 }
1248 } 1248 }
Line 1493... Line 1493...
1493 fprintf(stdout, "Version: %s \n", PROGRAM_VERSION); 1493 fprintf(stdout, "Version: %s \n", PROGRAM_VERSION);
1494 fprintf(stdout, " \n"); 1494 fprintf(stdout, " \n");
1495 fprintf(stdout, "SYNTAX: %s [-q] <-a|-r|-c> <PATH PATH PATH...> \n", name); 1495 fprintf(stdout, "SYNTAX: %s [-q] <-a|-r|-c> <PATH PATH PATH...> \n", name);
1496 fprintf(stdout, " \n"); 1496 fprintf(stdout, " \n");
1497 fprintf(stdout, "Required: \n"); 1497 fprintf(stdout, "Required: \n");
1498 fprintf(stdout, " -a [PATH...] Add files (default). \n"); 1498 fprintf(stdout, " -a [PATH...] Add files. \n");
1499 fprintf(stdout, " -c [PATH...] Create database from scratch. \n"); 1499 fprintf(stdout, " -c [PATH...] Create from scratch. \n");
1500 fprintf(stdout, " -r [PATH...] Remove files. \n"); 1500 fprintf(stdout, " -r [PATH...] Remove files. \n");
1501 fprintf(stdout, " \n"); 1501 fprintf(stdout, " \n");
1502 fprintf(stdout, "Optional: \n"); 1502 fprintf(stdout, "Optional: \n");
1503 fprintf(stdout, " -d [FIILE] Where to store the database. \n"); 1503 fprintf(stdout, " -d [FIILE] Where to store the database. \n");
1504 fprintf(stdout, " -m BYTES Memory to use (default: %d). \n", maxmem); 1504 fprintf(stdout, " -m BYTES Memory to use (default: %d). \n", maxmem);