<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugzilla.globus.org/bugzilla/bugzilla.dtd">

<bugzilla version="3.2.3"
          urlbase="http://bugzilla.globus.org/bugzilla/"
          maintainer="bacon@mcs.anl.gov"
>

    <bug>
          <bug_id>5967</bug_id>
          
          <creation_ts>2008-03-31 10:21</creation_ts>
          <short_desc>LIGO: -i option to globus-rls-cli requires file end with end-of-line character</short_desc>
          <delta_ts>2008-05-28 19:16:00</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Replica Location</product>
          <component>RLS</component>
          <version>development</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Scott Koranda">skoranda@gravity.phys.uwm.edu</reporter>
          <assigned_to name="Rob S">schuler@isi.edu</assigned_to>
          <cc>annc@isi.edu</cc>
    
    <cc>shishir@isi.edu</cc>

      

      
          <long_desc isprivate="0">
            <who name="Scott Koranda">skoranda@gravity.phys.uwm.edu</who>
            <bug_when>2008-03-31 10:21:06</bug_when>
            <thetext>The -i option to globus-rls-cli will fail on the last line of an input file if it does not end with an end-of-line character but instead ends with EOF. The error received is

ERROR: Input line length &gt; 1024

The problem is this bit of code:

if (ptr &amp;&amp; ptr[strlen(ptr)-1]!=&apos;\n&apos;) { /* long line check */
    fprintf(stderr, &quot;ERROR: Input line length &gt; %d\n&quot;, MAX_BULK_LINE_LENGTH);
    cleanexit(1);
  }

While it is true that in UNIX a plain text file that does not end in &apos;\n&apos; is considered malformed, it would be nice if globus-rls-cli could handle the last line ending with EOF and not &apos;\n&apos;.

So please consider this an enhancement request.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who name="Rob S">schuler@isi.edu</who>
            <bug_when>2008-04-02 18:47:17</bug_when>
            <thetext>OK. I&apos;ve changed that. It should work now. Also, I made a couple additional changes. First, I also added the return &apos;\r&apos; character as a string token delimiter, just in case. And I added line numbers to the error message output. I can just imagine a LIGO sysadmin getting a message that a line is too long or a line has too few arguments and then having to go figure out which one out of thousands of lines!

Summary:
1. Accept EOF as terminator of last line
2. Add &apos;\r&apos; for token delimiters
3. Output line numbers on error messages

The changes are committed to TRUNK since the &apos;-i&apos; option has not yet been backported to the globus_4_0_branch. Plan is to backport the &apos;-i&apos; feature (which will have this fix) before 4.0.8.

Here&apos;s a diff and then a code snip.

Diff:
-----
Index: cli.c
===================================================================
RCS file: /home/globdev/CVS/globus-packages/replica/rls/client/cli.c,v
retrieving revision 1.15
diff -r1.15 cli.c
745a746
&gt;   int  lineno;
789,793c790
&lt;   if (ptr &amp;&amp; ptr[strlen(ptr)-1]!=&apos;\n&apos;) { /* long line check */
&lt;     fprintf(stderr, &quot;ERROR: Input line length &gt; %d\n&quot;, MAX_BULK_LINE_LENGTH);
&lt;     cleanexit(1);
&lt;   }
&lt;   if (feof(in-&gt;infile)) {
---
&gt;   if (!ptr &amp;&amp; feof(in-&gt;infile)) {
796c793,798
&lt;   in-&gt;fargv[0]=strtok(ptr, &quot; \t\n&quot;);
---
&gt;   if (ptr &amp;&amp; !feof(in-&gt;infile) &amp;&amp; ptr[strlen(ptr)-1]!=&apos;\n&apos;) { /* long line check */
&gt;     fprintf(stderr, &quot;ERROR: Input line length exceeds %d on line %d\n&quot;, 
&gt;             MAX_BULK_LINE_LENGTH, in-&gt;lineno);
&gt;     cleanexit(1);
&gt;   }
&gt;   in-&gt;fargv[0]=strtok(ptr, &quot; \t\r\n&quot;);
798,799c800,803
&lt;     if (! (in-&gt;fargv[i]=strtok(NULL, &quot; \t\n&quot;)) )
&lt;       fprintf(stderr, &quot;ERROR: Input line too short.  Not enough args.\n&quot;);
---
&gt;     if (! (in-&gt;fargv[i]=strtok(NULL, &quot; \t\r\n&quot;)) ) {
&gt;       fprintf(stderr, &quot;ERROR: Input line too short. Not enough args on line %d\n&quot;, in-&gt;lineno);
&gt;       cleanexit(1);
&gt;     }
800a805
&gt;   in-&gt;lineno++;
807a813
&gt;   s-&gt;lineno = 0;
819a826
&gt;   s-&gt;lineno = 1;
-----

Snip:
-----
static char **
bulk_next_args_from_file(bulk_input *in)

{
  char *line;
  char *ptr;
  int i;

  assert(in-&gt;pos &lt; MAX_BULK_ELEMENTS);
  line=(in-&gt;inbuf)+((MAX_BULK_LINE_LENGTH+1) * in-&gt;pos);
  in-&gt;pos++;

  if (feof(in-&gt;infile)) {
    return NULL;
  }
  ptr = fgets(line, MAX_BULK_LINE_LENGTH, in-&gt;infile);
  if (!ptr &amp;&amp; feof(in-&gt;infile)) {
    return NULL;
  }
  if (ptr &amp;&amp; !feof(in-&gt;infile) &amp;&amp; ptr[strlen(ptr)-1]!=&apos;\n&apos;) { /* long line check */
    fprintf(stderr, &quot;ERROR: Input line length exceeds %d on line %d\n&quot;,
            MAX_BULK_LINE_LENGTH, in-&gt;lineno);
    cleanexit(1);
  }
  in-&gt;fargv[0]=strtok(ptr, &quot; \t\r\n&quot;);
  for (i=1; i &lt; in-&gt;step; i++) {
    if (! (in-&gt;fargv[i]=strtok(NULL, &quot; \t\r\n&quot;)) ) {
      fprintf(stderr, &quot;ERROR: Input line too short. Not enough args on line %d\n&quot;, in-&gt;lineno);
      cleanexit(1);
    }
  }
  in-&gt;lineno++;
  return in-&gt;fargv;
}
-----</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who name="Rob S">schuler@isi.edu</who>
            <bug_when>2008-04-03 10:35:56</bug_when>
            <thetext>I forgot. One additional thing that was fixed was a Segmentation Fault on exit when there were too few arguments. Now it exits cleanly.</thetext>
          </long_desc>
      
      

    </bug>

</bugzilla>