"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/src/gretl_xml.c" between
gretl-2020a.tar.xz and gretl-2020b.tar.xz

About: gretl (Gnu Regression, Econometrics and Time-series Library) is a cross-platform statistical package mainly for econometric analysis.

gretl_xml.c  (gretl-2020a.tar.xz):gretl_xml.c  (gretl-2020b.tar.xz)
skipping to change at line 2026 skipping to change at line 2026
} }
nv = nvars + 2; nv = nvars + 2;
for (i=1; i<=nv && !err; i++) { for (i=1; i<=nv && !err; i++) {
if (i <= nvars) { if (i <= nvars) {
v = savenum(list, i); v = savenum(list, i);
} else { } else {
v = (i == nvars + 1)? uv : tv; v = (i == nvars + 1)? uv : tv;
} }
s = 0; s = 0;
if (opt & OPT_O) { for (t=dset->t1; t<=dset->t2 && !err; t++) {
/* --oldbinary */ if (dset->Z[uv][t] != 0.0) {
double zvt; tmp[s++] = dset->Z[v][t];
for (t=dset->t1; t<=dset->t2 && !err; t++) {
if (dset->Z[uv][t] != 0.0) {
zvt = dset->Z[v][t];
tmp[s++] = na(zvt) ? DBL_MAX : zvt;
}
}
} else {
for (t=dset->t1; t<=dset->t2 && !err; t++) {
if (dset->Z[uv][t] != 0.0) {
tmp[s++] = dset->Z[v][t];
}
} }
} }
wrote = fwrite(tmp, sizeof(double), nrows, fp); wrote = fwrite(tmp, sizeof(double), nrows, fp);
if (wrote != nrows) { if (wrote != nrows) {
err = E_DATA; err = E_DATA;
} }
} }
free(tmp); free(tmp);
if (uv > 0) { if (uv > 0) {
dataset_drop_last_variables((DATASET *) dset, 2); dataset_drop_last_variables((DATASET *) dset, 2);
} }
} else if (opt & OPT_O) {
/* --oldbinary: convert NAs to DBL_MAX */
const double *zv;
double zvt;
int t;
for (i=1; i<=nvars && !err; i++) {
v = savenum(list, i);
zv = dset->Z[v] + dset->t1;
wrote = 0;
for (t=0; t<T; t++) {
zvt = na(zv[t]) ? DBL_MAX : zv[t];
wrote += fwrite(&zvt, sizeof(double), 1, fp);
}
if (wrote != T) {
err = E_DATA;
}
}
} else { } else {
for (i=1; i<=nvars && !err; i++) { for (i=1; i<=nvars && !err; i++) {
v = savenum(list, i); v = savenum(list, i);
wrote = fwrite(dset->Z[v] + dset->t1, sizeof(double), wrote = fwrite(dset->Z[v] + dset->t1, sizeof(double),
T, fp); T, fp);
if (wrote != T) { if (wrote != T) {
err = E_DATA; err = E_DATA;
} }
} }
} }
skipping to change at line 2297 skipping to change at line 2267
if (!has_suffix(fname, ".gdt")) { if (!has_suffix(fname, ".gdt")) {
/* force use of .gdt extension for native XML data */ /* force use of .gdt extension for native XML data */
path = fullname = g_strdup_printf("%s.gdt", fname); path = fullname = g_strdup_printf("%s.gdt", fname);
} }
prn = open_gdt_write_stream(path, opt); prn = open_gdt_write_stream(path, opt);
g_free(fullname); g_free(fullname);
} }
if (prn == NULL) { if (prn == NULL) {
fprintf(stderr, "HERE 2 NULL prn\n");
free(list); free(list);
return E_FOPEN; return E_FOPEN;
} }
dsize = tsamp * nvars * sizeof(double); dsize = tsamp * nvars * sizeof(double);
if (dsize > 100000) { if (dsize > 100000) {
fprintf(stderr, I_("Writing %.0f Kbytes of data\n"), dsize / 1024); fprintf(stderr, I_("Writing %.0f Kbytes of data\n"), dsize / 1024);
} else if (progress) { } else if (progress) {
/* suppress progress bar for smaller data */ /* suppress progress bar for smaller data */
skipping to change at line 2563 skipping to change at line 2532
char *sbuf, **strs; char *sbuf, **strs;
int j, n_strs; int j, n_strs;
pprintf(prn, "<string-tables count=\"%d\">\n", ntabs); pprintf(prn, "<string-tables count=\"%d\">\n", ntabs);
for (i=1; i<=nvars; i++) { for (i=1; i<=nvars; i++) {
v = savenum(list, i); v = savenum(list, i);
if (!is_string_valued(dset, v)) { if (!is_string_valued(dset, v)) {
continue; continue;
} }
strs = series_get_string_vals(dset, v, &n_strs); strs = series_get_string_vals(dset, v, &n_strs, 0);
gretl_xml_encode_to_buf(xmlbuf, dset->varname[v], sizeof xmlbuf); gretl_xml_encode_to_buf(xmlbuf, dset->varname[v], sizeof xmlbuf);
pprintf(prn, "<valstrings owner=\"%s\" count=\"%d\">", xmlbuf, n_strs ); pprintf(prn, "<valstrings owner=\"%s\" count=\"%d\">", xmlbuf, n_strs );
for (j=0; j<n_strs; j++) { for (j=0; j<n_strs; j++) {
sbuf = gretl_xml_encode(strs[j]); sbuf = gretl_xml_encode(strs[j]);
if (sbuf == NULL || *sbuf == '\0') { if (sbuf == NULL || *sbuf == '\0') {
fprintf(stderr, "string values for var %d: string %d is empty \n", fprintf(stderr, "string values for var %d: string %d is empty \n",
i, j); i, j);
pputs(prn, "\"empty string\" "); pputs(prn, "\"empty string\" ");
} else { } else {
pprintf(prn, "\"%s\" ", sbuf); pprintf(prn, "\"%s\" ", sbuf);
 End of changes. 4 change blocks. 
35 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)