Changeset 8633
- Timestamp:
- Aug 26, 2006, 10:02:50 AM (20 years ago)
- Location:
- trunk/Ohana/src/libohana
- Files:
-
- 3 added
- 3 edited
-
Makefile (modified) (5 diffs)
-
include/ohana.h (modified) (1 diff)
-
src/string.c (modified) (1 diff)
-
test (added)
-
test/.cvsignore (added)
-
test/string.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libohana/Makefile
r8303 r8633 6 6 MAN = $(HOME)/doc 7 7 INC = $(HOME)/include 8 TESTDIR = $(HOME)/test 9 TESTLIB = $(ROOT)/src/libtap/lib/$(ARCH) 10 TESTINC = $(ROOT)/src/libtap/include 8 11 DESTBIN = $(LBIN) 9 12 DESTLIB = $(LLIB) … … 11 14 DESTMAN = $(LMAN) 12 15 13 CFLAGS = -I$(LINC) -D$(ARCH) 16 LIBS = -L$(LLIB) -L$(XLIB) -lohana 17 CFLAGS = -I$(INC) -I$(LINC) -D$(ARCH) 18 TFLAGS = $(CFLAGS) $(LIBS) -L$(TESTLIB) -I$(TESTINC) -ltap 14 19 15 20 default: install … … 37 42 $(SRC)/version.$(ARCH).o 38 43 44 TEST = \ 45 $(TESTDIR)/string.$(ARCH) 46 39 47 $(OBJS): $(INCS) 40 48 … … 55 63 cp $(INC)/$* $(DESTINC)/ 56 64 65 $(TESTDIR)/%.$(ARCH) : $(DESTLIB)/libohana.a $(TESTDIR)/%.c 66 $(CC) $^ -o $@ $(TFLAGS) 67 68 testcode: install $(TEST) 69 70 test: 71 make testcode 72 for i in $(TEST); do $$i; done 73 57 74 clean: 58 75 rm -f */*~ … … 66 83 67 84 .c.$(ARCH).o: 85 echo make c 86 echo $(CFLAGS) 87 echo $*.c 88 echo $@ 68 89 $(CC) $(CFLAGS) -c $*.c -o $@ 90 91 .PHONY: test -
trunk/Ohana/src/libohana/include/ohana.h
r8385 r8633 115 115 int remove_argument PROTO((int N, int *argc, char **argv)); 116 116 void uppercase PROTO((char *string)); 117 char *strsubs PROTO((char *string, char *match, char *with)); 117 118 118 119 /* in findexec.c */ -
trunk/Ohana/src/libohana/src/string.c
r3508 r8633 69 69 } 70 70 71 // replace a single entry of 'match' in the string with 'with' 72 // (quick-and-dirty regex for a common case...) 73 char *strsubs (char *string, char *match, char *with) { 74 75 int N1, N2, N3; 76 char *root; 77 char *out; 78 char *ext; 79 80 if (string == NULL) return NULL; 81 if (match == NULL) return NULL; 82 if (with == NULL) return NULL; 83 84 root = strstr (string, match); 85 if (root == NULL) { 86 return (strcreate (string)); 87 } 88 N1 = root - string; 89 90 N2 = strlen (with); 91 92 ext = root + strlen(match); 93 N3 = strlen (ext); 94 95 ALLOCATE (out, char *, N1 + N2 + N3 + 1); 96 97 strncpy (out, string, N1); 98 strncpy (&out[N1], with, N2); 99 strncpy (&out[N1+N2], ext, N3); 100 out[N1+N2+N3] = 0; 101 102 return out; 103 } 104 105 # if 0 106 // replace a single entry of 'match' in the string with 'with' 107 // (quick-and-dirty regex for a common case...) 108 char *strrsubs (char *string, char *match, char *with) { 109 110 char *root; 111 char *out; 112 113 if (string == NULL) return NULL; 114 if (match == NULL) return NULL; 115 if (with == NULL) return NULL; 116 117 root = strstr (string, match); 118 if (root == NULL) return NULL; 119 120 ext = string + strlen (match); 121 ALLOCATE (out, char *, strlen(with) + strlen(ext) + 1); 122 strcpy (out, with); 123 strcat (out, ext); 124 125 return out; 126 } 127 # endif 128 71 129 int scan_line (FILE *f, char *line) { 72 130
Note:
See TracChangeset
for help on using the changeset viewer.
