|
From: <kin...@us...> - 2003-11-16 06:05:18
|
Update of /cvsroot/teem/teem/src/nrrd
In directory sc8-pr-cvs1:/tmp/cvs-serv19779
Modified Files:
comment.c nrrd.h
Log Message:
API CHANGE: removed nrrdCommentScan, since key/value pairs have superseded this functionality
Index: comment.c
===================================================================
RCS file: /cvsroot/teem/teem/src/nrrd/comment.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** comment.c 14 Nov 2003 17:52:29 -0000 1.15
--- comment.c 16 Nov 2003 06:04:35 -0000 1.16
***************
*** 82,156 ****
/*
- ******** nrrdCommentScan()
- **
- ** looks through comments of nrrd for something of the form
- ** " <key> : <val>"
- ** There can be whitespace anywhere it appears in the format above.
- ** The division between key and val is the first colon which appears.
- ** A colon may not appear in the key. Returns a pointer to the beginning
- ** of "val", as it occurs in the string pointed to by the nrrd struct:
- ** No new memory is allocated.
- **
- ** If there is an error (including the key is not found), returns NULL,
- ** but DOES NOT USE BIFF for errors (since such "errors" are more often
- ** than not actually problems).
- */
- char *
- nrrdCommentScan(Nrrd *nrrd, const char *key) {
- /* char me[]="nrrdCommentScan"; */
- int i;
- char *cmt, *k, *c, *t, *ret=NULL;
-
- if (!(nrrd && airStrlen(key)))
- return NULL;
-
- if (!nrrd->cmt) {
- /* no comments to scan */
- return NULL;
- }
- if (strchr(key, ':')) {
- /* key contains colon- would confuse later steps */
- return NULL;
- }
- for (i=0; i<nrrd->cmtArr->len; i++) {
- cmt = nrrd->cmt[i];
- /* printf("%s: looking at comment \"%s\"\n", me, cmt); */
- if ((k = strstr(cmt, key)) && (c = strchr(cmt, ':'))) {
- /* is key before colon? */
- if (!( k+strlen(key) <= c ))
- goto nope;
- /* is there only whitespace before the key? */
- t = cmt;
- while (t < k) {
- if (!isspace(*t))
- goto nope;
- t++;
- }
- /* is there only whitespace after the key? */
- t = k+strlen(key);
- while (t < c) {
- if (!isspace(*t))
- goto nope;
- t++;
- }
- /* is there something after the colon? */
- t = c+1;
- while (isspace(*t)) {
- t++;
- }
- if (!*t)
- goto nope;
- /* t now points to beginning of "value" string; we're done */
- ret = t;
- /* printf("%s: found \"%s\"\n", me, t); */
- break;
- }
- nope:
- ret = NULL;
- }
- return ret;
- }
-
- /*
******** nrrdCommentCopy()
**
--- 82,85 ----
Index: nrrd.h
===================================================================
RCS file: /cvsroot/teem/teem/src/nrrd/nrrd.h,v
retrieving revision 1.121
retrieving revision 1.122
diff -C2 -d -r1.121 -r1.122
*** nrrd.h 14 Nov 2003 17:54:05 -0000 1.121
--- nrrd.h 16 Nov 2003 06:04:35 -0000 1.122
***************
*** 559,563 ****
extern void nrrdCommentClear(Nrrd *nrrd);
extern int nrrdCommentCopy(Nrrd *nout, const Nrrd *nin);
- extern char *nrrdCommentScan(Nrrd *nrrd, const char *key);
/******** key/value pairs */
--- 559,562 ----
|