Changeset 38377
- Timestamp:
- Jun 5, 2015, 11:18:52 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libohana
- Files:
-
- 5 edited
-
Makefile (modified) (5 diffs)
-
include/ohana.h (modified) (1 diff)
-
src/string.c (modified) (2 diffs)
-
test (modified) (1 prop)
-
test/string.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libohana/Makefile
r37807 r38377 1 1 default: install 2 2 help: 3 @echo "make options: install libohana clean dist test t ypetest"3 @echo "make options: install libohana clean dist test test.clean" 4 4 5 5 include ../../Makefile.System … … 10 10 MAN = $(HOME)/doc 11 11 INC = $(HOME)/include 12 TESTDIR = $(HOME)/test 12 TESTDIR = $(HOME)/test 13 TESTBIN = $(HOME)/test 13 14 include ../../Makefile.Common 14 15 … … 17 18 FULL_CPPFLAGS = $(BASE_CPPFLAGS) 18 19 FULL_LDFLAGS = $(BASE_LDFLAGS) 19 TFLAGS = $(FULL_CFLAGS) $(FULL_CPPFLAGS) $(FULL_LDFLAGS) -lohana -ltap_ohana20 20 21 install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE) typetest 21 TEST_CFLAGS = $(BASE_CFLAGS) 22 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 23 TEST_LDFLAGS = $(BASE_LDFLAGS) -lohana -ltap_ohana 24 25 install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE) 22 26 libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).$(DLLTYPE) 23 27 … … 51 55 # $(SRC)/gsl_utils.$(ARCH).o \ 52 56 53 TYPETEST = \54 $(TESTDIR)/typetest.$(ARCH)55 56 $(TYPETEST) : $(LIB)/libohana.$(ARCH).a57 58 typetest: $(TYPETEST)59 for i in $(TYPETEST); do $$i || exit 1; done60 61 TEST = \62 $(TESTDIR)/memtest.$(ARCH)63 # $(TESTDIR)/string.$(ARCH)64 65 testcode: install $(TEST)66 test:67 $(MAKE) testcode68 for i in $(TEST); do $$i; done69 70 quicktest:71 for i in $(TEST); do $$i; done72 73 57 $(OBJS): $(INCS) 74 58 … … 79 63 $(DESTLIB)/libohana.$(DLLTYPE): $(LIB)/libohana.$(ARCH).$(DLLTYPE) 80 64 81 $(TESTDIR)/%.$(ARCH) : $(TESTDIR)/%.c 82 $(CC) $^ -o $@ $(TFLAGS) 65 TESTPROG = memtest typetest string 66 $(TESTPROG) : % : $(TESTBIN)/% $(OBJS) 67 test: $(TESTPROG) 68 for i in $(TESTPROG); do $(TESTBIN)/$$i; done 83 69 84 .PHONY: test85 -
branches/eam_branches/ohana.20150429/src/libohana/include/ohana.h
r38372 r38377 286 286 char *strcreate PROTO((char *string)); 287 287 char *strncreate PROTO((char *string, int n)); 288 int strextend PROTO((char * input, char *format,...)) OHANA_FORMAT(printf, 2, 3);288 int strextend PROTO((char **input, char *format,...)) OHANA_FORMAT(printf, 2, 3); 289 289 int scan_line PROTO((FILE *f, char *line)); 290 290 int scan_line_maxlen PROTO((FILE *f, char *line, int maxlen)); -
branches/eam_branches/ohana.20150429/src/libohana/src/string.c
r38372 r38377 51 51 } 52 52 53 int strextend (char *input, char *format,...) {54 55 char tmpextra[1024], tmpline[1024];56 va_list argp;57 58 va_start (argp, format);59 vsnprintf (tmpextra, 1024, format, argp);60 snprintf (tmpline, 1024, "%s %s", input, tmpextra);61 strcpy (input, tmpline);62 63 return TRUE;64 }65 66 53 /* create a new string of length n from this string */ 67 54 char *strncreate (char *string, int n) { … … 76 63 line[n] = 0; 77 64 return (line); 65 } 66 67 // extend input as needed to add the formatted pieces 68 // if input is NULL, allocate a new line 69 // the result of the format must be < 1024 bytes 70 int strextend (char **input, char *format,...) { 71 72 int Nchar; 73 char tmpextra[1024], tmpline, *output; 74 va_list argp; 75 76 va_start (argp, format); 77 Nchar = vsnprintf (tmpextra, 1024, format, argp); 78 if (Nchar > 1024 - 1) return FALSE; 79 80 if (*input) { 81 Nchar = snprintf (&tmpline, 0, "%s %s", *input, tmpextra); 82 ALLOCATE (output, char, Nchar + 1); 83 snprintf (output, Nchar + 1, "%s %s", *input, tmpextra); 84 free (*input); 85 } else { 86 Nchar = strlen(tmpextra) + 1; 87 ALLOCATE (output, char, Nchar); 88 strcpy (output, tmpextra); 89 } 90 *input = output; 91 92 return TRUE; 78 93 } 79 94 -
branches/eam_branches/ohana.20150429/src/libohana/test
- Property svn:ignore
-
old new 4 4 *.darwin_x86 5 5 *.dSYM 6 memtest 7 string 8 typetest
-
- Property svn:ignore
-
branches/eam_branches/ohana.20150429/src/libohana/test/string.c
r10313 r38377 4 4 int main (void) { 5 5 6 plan_tests ( 16);6 plan_tests (20); 7 7 8 8 diag ("libohana string.c tests"); … … 67 67 skip_end(); 68 68 } 69 70 /*** strextend ***/ 71 { 72 int status; 73 char *string = NULL; 74 75 status = strextend(&string, "hello %s", "there"); 76 ok (status, "strextend for NULL input"); 77 ok (!strcmp(string, "hello there"), "strextend format"); 78 79 status = strextend(&string, "more words %d", 2); 80 ok (status, "strextend for non-NULL input"); 81 ok (!strcmp(string, "hello there more words 2"), "strextend format"); 82 } 83 69 84 return exit_status(); 70 85 }
Note:
See TracChangeset
for help on using the changeset viewer.
