HuntnGather – Diff between revs 41 and 43
?pathlinks?
Rev 41 | Rev 43 | |||
---|---|---|---|---|
Line 62... | Line 62... | |||
62 | |
62 | |
|
63 | /* |
63 | /* |
|
64 | * |
64 | * |
|
65 | * Converts a string to case. |
65 | * Converts a string to case. |
|
- | 66 | */ |
||
- | 67 | #if defined ___AmigaOS___ |
||
- | 68 | void StrUpr(UBYTE *s) { |
||
66 | */ |
69 | #else |
|
- | 70 | void StrUpr(char *s) { |
||
67 | void StrUpr(char *s) { |
71 | #endif |
|
68 | while(*s != '\0') { |
72 | while(*s != '\0') { |
|
69 | #if defined ___AmigaOS___ |
73 | #if defined ___AmigaOS___ |
|
70 | *s = ToUpper(*s); |
74 | *s = ToUpper(*s); |
|
71 | #else |
75 | #else |
|
Line 507... | Line 511... | |||
507 | |
511 | |
|
508 | return line; |
512 | return line; |
|
Line 509... | Line 513... | |||
509 | } |
513 | } |
|
510 | |
514 | |
|
511 | /* |
515 | /* |
|
512 | * |
516 | * |
|
513 | * Delete a file. |
517 | * Delete a file. |
|
514 | */ |
518 | */ |
|
515 | #if defined ___AmigaOS___ |
519 | #if defined ___AmigaOS___ |
|
516 | BOOL RemoveFile(char *name) { |
520 | BOOL RemoveFile(char *name) { |
|
517 | return DeleteFile(name); |
521 | return DeleteFile(name); |
|
Line 538... | Line 542... | |||
538 | |
542 | |
|
539 | /* |
543 | /* |
|
540 | * |
544 | * |
|
541 | * Copies a file to another file by name. |
545 | * Copies a file to another file by name. |
|
542 | */ |
546 | */ |
|
543 | void CopyFile(char *a, char *b) { |
547 | void CopyLines(char *a, char *b) { |
|
544 | #if defined ___AsyncIO___ |
548 | #if defined ___AsyncIO___ |
|
545 | struct AsyncFile *ap; |
549 | struct AsyncFile *ap; |
|
546 | struct AsyncFile *bp; |
- | ||
547 | LONG c; |
550 | struct AsyncFile *bp; |
|
548 | #else |
551 | #else |
|
549 | FILE *ap; |
552 | FILE *ap; |
|
550 | FILE *bp; |
- | ||
551 | char c; |
553 | FILE *bp; |
|
- | 554 | #endif |
||
Line 552... | Line 555... | |||
552 | #endif |
555 | dbLine *line = NULL; |
|
553 | |
556 | |
|
554 | // Open database file for writing. |
557 | // Open database file for writing. |
|
555 | #if defined ___AsyncIO___ |
558 | #if defined ___AsyncIO___ |
|
Line 577... | Line 580... | |||
577 | #endif |
580 | #endif |
|
Line 578... | Line 581... | |||
578 | |
581 | |
|
579 | return; |
582 | return; |
|
Line 580... | Line -... | |||
580 | } |
- | ||
581 | |
583 | } |
|
582 | #if defined ___AsyncIO___ |
- | ||
583 | while(PROGRAM_RUN && (c = ReadCharAsync(ap)) != -1) { |
- | ||
584 | #else |
- | ||
585 | while(PROGRAM_RUN && fscanf(ap, "%c", &c) == 1) { |
584 | |
|
586 | #endif |
585 | while(PROGRAM_RUN && (line = ReadLine(ap)) != NULL) { |
|
587 | #if defined ___AmigaOS___ |
586 | #if defined ___AmigaOS___ |
|
588 | // Check if CTRL+C was pressed and abort the program. |
587 | // Check if CTRL+C was pressed and abort the program. |
|
589 | if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
588 | if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
|
590 | PROGRAM_RUN = FALSE; |
589 | PROGRAM_RUN = FALSE; |
|
591 | continue; |
590 | continue; |
|
- | 591 | } |
||
592 | } |
592 | #endif |
|
- | 593 | |
||
593 | #endif |
594 | #if defined ___AsyncIO___ |
|
594 | #if defined ___AsyncIO___ |
595 | WriteAsync(bp, line->string, line->length); |
|
595 | if(WriteCharAsync(bp, (UBYTE)c) != 1) { |
596 | WriteAsync(bp, "\n", 1); |
|
596 | #else |
597 | #else |
|
- | 598 | fprintf(bp, "%s\n", line->string); |
||
597 | if(fprintf(bp, "%c", c) != 1) { |
599 | #endif |
|
598 | #endif |
600 | |
|
- | 601 | free(line->string); |
||
599 | fprintf(stderr, "Could not write to file '%s'.\n", b); |
602 | free(line); |
|
- | 603 | line = NULL; |
||
- | 604 | } |
||
- | 605 | |
||
- | 606 | if(line != NULL) { |
||
- | 607 | free(line->string); |
||
600 | break; |
608 | free(line); |
|
Line 601... | Line 609... | |||
601 | } |
609 | line = NULL; |
|
602 | } |
610 | } |
|
603 | |
611 | |
|
Line 678... | Line 686... | |||
678 | #endif |
686 | #endif |
|
679 | #if defined ___AmigaOS___ |
687 | #if defined ___AmigaOS___ |
|
680 | ULONG size; |
688 | ULONG size; |
|
681 | BOOL success; |
689 | BOOL success; |
|
682 | UBYTE *pattern; |
690 | UBYTE *pattern; |
|
- | 691 | char *e = a; |
||
- | 692 | char *n = b; |
||
- | 693 | |
||
- | 694 | #if defined ___NOCASE_FS___ |
||
- | 695 | StrUpr(e); |
||
- | 696 | StrUpr(n); |
||
- | 697 | #endif |
||
Line 683... | Line 698... | |||
683 | |
698 | |
|
684 | // "must be at least 2 times as large plus 2 bytes" |
699 | // "must be at least 2 times as large plus 2 bytes" |
|
Line 685... | Line 700... | |||
685 | size = strlen(b) * 2 + 2; |
700 | size = strlen(n) * 2 + 2; |
|
Line 686... | Line 701... | |||
686 | |
701 | |
|
687 | success = FALSE; |
702 | success = FALSE; |
|
688 | |
703 | |
|
689 | if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
704 | if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
|
Line 690... | Line 705... | |||
690 | switch(ParsePatternNoCase(b, pattern, (LONG)size)) { |
705 | switch(ParsePatternNoCase(n, pattern, (LONG)size)) { |
|
691 | case 1: // the pattern contains wildcards |
706 | case 1: // the pattern contains wildcards |
|
692 | success = MatchPatternNoCase(pattern, a); |
707 | success = MatchPatternNoCase(pattern, e); |
|
693 | |
708 | |
|
694 | break; |
709 | break; |
|
695 | case 0: // no wildcards so fall back to exact name match |
710 | case 0: // no wildcards so fall back to exact name match |
|
696 | #if defined ___NOCASE_FS___ |
711 | #if defined ___NOCASE_FS___ |
|
Line 697... | Line 712... | |||
697 | success = (Strnicmp(a, b, StringLenMax(a, b)) == 0); |
712 | success = (Strnicmp(e, n, StringLenMax(e, n)) == 0); |
|
698 | #else |
713 | #else |