From: pjk Date: Thu, 13 May 2004 17:51:22 +0000 (+0000) Subject: Add support for (TAB) to DATA LIST FREE/LIST X-Git-Tag: v0.4.0~264 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c7efcb9a47f141c7bb6a50def0bb88dbaa0c38f;p=pspp-builds.git Add support for (TAB) to DATA LIST FREE/LIST --- diff --git a/src/data-list.c b/src/data-list.c index 92be7cb8..a80fff30 100644 --- a/src/data-list.c +++ b/src/data-list.c @@ -88,6 +88,7 @@ struct data_list_pgm int eof; /* End of file encountered. */ int nrec; /* Number of records. */ size_t case_size; /* Case size in bytes. */ + int delim; /* Specified delimeter */ }; static int parse_fixed (struct data_list_pgm *); @@ -120,6 +121,7 @@ cmd_data_list (void) dls->end = NULL; dls->eof = 0; dls->nrec = 0; + dls->delim=0; dls->first = dls->last = NULL; while (token != '/') @@ -198,6 +200,13 @@ cmd_data_list (void) else table = index - 3; } + else if (token=='(') { + lex_get(); + if (lex_match_id ("TAB")) { + dls->delim='\t'; + } + lex_get(); + } else { lex_error (NULL); @@ -947,10 +956,16 @@ cut_field (const struct data_list_pgm *dls, char **ret_cp, int *ret_len) return 0; ep = cp + len; + if (dls->delim != 0) { + if (*cp==dls->delim) { + cp++; + } + } else { - /* Skip leading whitespace and commas. */ - while ((isspace ((unsigned char) *cp) || *cp == ',') && cp < ep) - cp++; + /* Skip leading whitespace and commas. */ + while ((isspace ((unsigned char) *cp) || *cp == ',') && cp < ep) + cp++; + } if (cp >= ep) return 0; @@ -962,17 +977,29 @@ cut_field (const struct data_list_pgm *dls, char **ret_cp, int *ret_len) *ret_cp = ++cp; while (cp < ep && *cp != quote) cp++; + if (dls->delim!=0) { + while(cpdelim) { + cp++; + } + } *ret_len = cp - *ret_cp; if (cp < ep) cp++; else - msg (SW, _("Scope of string exceeds line.")); + msg (SW, _("Scope of string exceeds line.")); } else { *ret_cp = cp; - while (cp < ep && !isspace ((unsigned char) *cp) && *cp != ',') - cp++; + if (dls->delim!=0) { + while(cpdelim) { + cp++; + } + } else { + + while (cp < ep && !isspace ((unsigned char) *cp) && *cp != ',') + cp++; + } *ret_len = cp - *ret_cp; } diff --git a/src/dfm.c b/src/dfm.c index dd9755ed..9f620294 100644 --- a/src/dfm.c +++ b/src/dfm.c @@ -463,12 +463,11 @@ read_record (struct file_handle *h) { while (ext->len && isspace ((unsigned char) ext->line[ext->len - 1])) ext->len--; - + /* Convert tabs to spaces. */ - tabs_to_spaces (h); - - ext->ptr = ext->line; - } + + ext->ptr = ext->line; + } return; eof: