Skip to content

Commit 3ec0385

Browse files
committed
address issue of text after colon in user comments
1 parent 7211d7f commit 3ec0385

File tree

6 files changed

+49
-23
lines changed

6 files changed

+49
-23
lines changed

c/xdifile.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
9595
char *header[MAX_LINES];
9696
char *words[MAX_WORDS], *cwords[2];
9797
char *col_labels[MAX_COLUMNS], *col_units[MAX_COLUMNS];
98-
char *c, *line, *mkey, *mval, *version_xdi, *version_extra;
98+
char *c, *line, *fullline, *mkey, *mval, *version_xdi, *version_extra;
9999
char *reword;
100100
char tlabel[32];
101101
char comments[1024] = "";
@@ -189,7 +189,9 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
189189

190190
if (strncmp(textlines[i], TOK_COMM, 1) == 0) {
191191
COPY_STRING(line, textlines[i]);
192+
COPY_STRING(fullline, textlines[i]);
192193
line++;
194+
fullline++;
193195
nwords = split_on(line, TOK_DELIM, words);
194196
if (nwords < 1) { continue; }
195197
COPY_STRING(mkey, words[0]);
@@ -270,10 +272,10 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
270272
if ((strlen(comments) > 0) && strlen(comments) < sizeof(comments)) {
271273
strncat(comments, "\n", sizeof(comments)-strlen(comments) - 1);
272274
}
273-
if (strlen(line) + 1 > sizeof(comments) - strlen(comments)) {
275+
if (strlen(fullline) + 1 > sizeof(comments) - strlen(comments)) {
274276
printf("Warning.... user comment may be truncated!\n");
275277
}
276-
strncat(comments, line, sizeof(comments) - strlen(comments) - 1);
278+
strncat(comments, fullline, sizeof(comments) - strlen(comments) - 1);
277279
} else if (mode == 0) {
278280
return ERR_META_FORMAT;
279281
}

perl/Makefile.PL

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11

2-
use Inline::MakeMaker;
2+
BEGIN {
3+
eval {
4+
require Inline::MakeMaker;
5+
};
6+
if ($@) {
7+
print "You need to install the 'Inline' perl module before building the XDI perl wrapper.
8+
See https://metacpan.org/release/Inline
9+
or install from a package for your system:
10+
debian/ubuntu: libinline-perl
11+
redhat/mandriva: perl-Inline
12+
suse: perl-Inline
13+
gentoo: dev-perl/Inline
14+
";
15+
exit;
16+
}
17+
}
18+
19+
import Inline::MakeMaker;
320

421
WriteMakefile(
522
NAME => 'Xray::XDI',
623
VERSION_FROM => 'lib/Xray/XDI.pm', # finds $VERSION
724
PREREQ_PM => {
825
Inline => 0.5,
26+
Inline::C => 0.62,
927
Moose => 2.06,
1028
'MooseX::NonMoose' => 0.22,
1129
'MooseX::Aliases' => 0.10,
@@ -31,4 +49,4 @@ WriteMakefile(
3149
# This work is published from: United States.
3250
#
3351
# Author: Bruce Ravel (bravel AT bnl DOT gov).
34-
# Last update: 8 September, 2012
52+
# Last update: 22 July, 2014

perl/README.org

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ to the XDI file format.
55

66
** INSTALLATION
77

8+
Before installation, you must somehow install perl's [[https://metacpan.org/release/Inline][Inline]] package.
9+
This can be installed from the ~cpan~ utility (=install Inline=) or
10+
using your system's package manager (~libinline-perl~ on debian & ubuntu,
11+
~perl-Inline~ on redhat, mandriva, & SUSE).
12+
813
To install this module type the following:
914

1015
: perl Makefile.PL
@@ -27,9 +32,10 @@ This module requires these modules, all available from cpan and as
2732
packages for major linux distributions:
2833

2934
1. Inline
30-
2. Moose
31-
3. MooseX::NonMoose
32-
4. MooseX::Aliases
35+
2. Inline::C
36+
3. Moose
37+
4. MooseX::NonMoose
38+
5. MooseX::Aliases
3339

3440

3541
** COPYRIGHT AND LICENCE
@@ -41,4 +47,5 @@ information about Authorship may be retained in some files for
4147
historical reasons, this work is hereby placed in the Public Domain.
4248
This work is published from: United States.
4349

44-
50+
Author: Bruce Ravel (bravel AT bnl DOT gov).
51+
Last update: 22 July, 2014

perl/lib/Xray/XDI.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,6 @@ historical reasons, this work is hereby placed in the Public Domain.
536536
This work is published from: United States.
537537
538538
Author: Bruce Ravel (bravel AT bnl DOT gov).
539-
Last update: 8 September, 2012
539+
Last update: 22 July, 2014
540540
541541
=cut

perl/lib/Xray/XDIFile.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ historical reasons, this work is hereby placed in the Public Domain.
100100
This work is published from: United States.
101101
102102
Author: Bruce Ravel (bravel AT bnl DOT gov).
103-
Last update: 8 September, 2012
103+
Last update: 22 July, 2014
104104
105105
=cut
106106

perl/t/writer/01_pp.t

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,17 @@ ok(ucfirst($xdi->element) eq ucfirst($new->element), 'element');
3131
ok(ucfirst($xdi->edge) eq ucfirst($new->edge), 'edge');
3232
ok(abs($xdi->dspacing - $new->dspacing) < $epsi, 'dspacing');
3333

34-
use Term::ANSIColor qw(:constants);
35-
use String::Diff;
36-
local %String::Diff::DEFAULT_MARKS = (
37-
remove_open => RED.REVERSE,
38-
remove_close => RESET,
39-
append_open => GREEN.REVERSE,
40-
append_close => RESET,
41-
);
42-
my($x, $n) = String::Diff::diff($xdi->comments, $new->comments);
43-
44-
print $x, $/, $/;
45-
print $n, $/;
34+
# use Term::ANSIColor qw(:constants);
35+
# use String::Diff;
36+
# local %String::Diff::DEFAULT_MARKS = (
37+
# remove_open => RED.REVERSE,
38+
# remove_close => RESET,
39+
# append_open => GREEN.REVERSE,
40+
# append_close => RESET,
41+
# );
42+
# my($x, $n) = String::Diff::diff($xdi->comments, $new->comments);
43+
# print $x, $/, $/;
44+
# print $n, $/;
4645

4746
ok($xdi->comments eq $new->comments, 'comments');
4847
ok($xdi->npts == $new->npts, 'npts');

0 commit comments

Comments
 (0)