IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8633


Ignore:
Timestamp:
Aug 26, 2006, 10:02:50 AM (20 years ago)
Author:
eugene
Message:

adding tap tests to libohana

Location:
trunk/Ohana/src/libohana
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libohana/Makefile

    r8303 r8633  
    66MAN     =       $(HOME)/doc
    77INC     =       $(HOME)/include
     8TESTDIR =       $(HOME)/test
     9TESTLIB =       $(ROOT)/src/libtap/lib/$(ARCH)
     10TESTINC =       $(ROOT)/src/libtap/include
    811DESTBIN =       $(LBIN)
    912DESTLIB =       $(LLIB)
     
    1114DESTMAN =       $(LMAN)
    1215
    13 CFLAGS  =       -I$(LINC) -D$(ARCH)
     16LIBS    =       -L$(LLIB) -L$(XLIB) -lohana
     17CFLAGS  =       -I$(INC) -I$(LINC) -D$(ARCH)
     18TFLAGS  =       $(CFLAGS) $(LIBS) -L$(TESTLIB) -I$(TESTINC) -ltap
    1419
    1520default: install
     
    3742$(SRC)/version.$(ARCH).o
    3843
     44TEST = \
     45$(TESTDIR)/string.$(ARCH)
     46
    3947$(OBJS): $(INCS)
    4048
     
    5563        cp $(INC)/$* $(DESTINC)/
    5664
     65$(TESTDIR)/%.$(ARCH) : $(DESTLIB)/libohana.a $(TESTDIR)/%.c
     66        $(CC) $^ -o $@ $(TFLAGS)
     67
     68testcode: install $(TEST)
     69
     70test:
     71        make testcode
     72        for i in $(TEST); do $$i; done
     73
    5774clean:
    5875        rm -f */*~
     
    6683
    6784.c.$(ARCH).o:
     85        echo make c
     86        echo $(CFLAGS)
     87        echo $*.c
     88        echo $@
    6889        $(CC) $(CFLAGS) -c $*.c -o $@
     90
     91.PHONY: test
  • trunk/Ohana/src/libohana/include/ohana.h

    r8385 r8633  
    115115int     remove_argument        PROTO((int N, int *argc, char **argv));
    116116void    uppercase              PROTO((char *string));
     117char   *strsubs                PROTO((char *string, char *match, char *with));
    117118
    118119/* in findexec.c */
  • trunk/Ohana/src/libohana/src/string.c

    r3508 r8633  
    6969}
    7070
     71// replace a single entry of 'match' in the string with 'with'
     72// (quick-and-dirty regex for a common case...)
     73char *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...)
     108char *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
    71129int scan_line (FILE *f, char *line) {
    72130
Note: See TracChangeset for help on using the changeset viewer.