mainAutoconf - Support: sr #110653, configure fails on AT&T UnixPC...

 
 

sr #110653: configure fails on AT&T UnixPC (3b1) due to faulty LINENO substitution

Submitter:  None
Submitted:  Sun 15 May 2022 11:03:13 AM UTC
   
 
Priority:  * 5 - Unprioritized Severity:  3 - Normal
Status:  Duplicate Privacy:  Public
Assigned to:  None Originator Email:  -email is unavailable-
Open/Closed:  Closed Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 16 May 2022 05:21:07 AM UTC, comment #1: 

Closing this as a duplicate of sr #110654.

Paul Eggert <eggert>
Group administrator
Sun 15 May 2022 11:03:13 AM UTC, original submission:  

Hi,

Autoconfigure scripts generated by GNU autoconf pass themselves through a pair sed script to substitute $LINENO variable with the actual line number if the shell itself does not support a $LINENO variable.

The first sed script adds a line with just the line number after each line containing $LINENO.
The second script then substitutes $LINENO with the contents of next line (the line number placed by first script)

This second script fails on AT&T UnixPC (3b1) and leaves some of the line numbers in the file on their line on their own.


This is due to a different behavior of sed's "t" command.
The "t" command branches to the given label if there has been a successful s/// substitution since the last t command.
On most other platforms, "t" only considers substitutions within current "line". However AT&T UnixPC's sed also considers substitutions on previous lines.

This breaks the second script if there are 2 lines with LINENO variable that have exactly one intervening other line between them.

Example:
abc $LINENO
def
fgh $LINENO

This is transformed by the first sed script into
abc $LINENO
1
def
fgh $LINENO
3

The second script first processes the first 2 lines into "abc 1"
However, the removal of the "1" from its own line (s/-\n.*//) is counted as a successful substitution, and is remembered (by UnixPC's sed) for the next line def (other sed implementations would clear this on passing to next line). As the sed script now thinks that def contains a $LINENO variable, it gobbles up the next line "fgh $LINENO" using N command, substitutes $LINENO with following line (i.e. with nothing, as it hasn't read the 3 into pattern space yet => eventually, it moves on to the next line (the unprocessed 3), and leaves this as is in the output.

Fix: this can be addressed by putting an empty branch + label at the end of the second sed script (t end \n :end):

...
    sed '
      s/[$]LINENO.*/&-/
      t lineno
      b
      :lineno
      N
      :loop
      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
      t loop
      s/-\n.*//
      t end
      :end
    ' >$as_me.lineno &&
...

in /usr/share/autoconf/m4sugar/m4sh.m4

N.B. For testing, an AT&T UnixPC emulator can be found at https://github.com/philpem/freebee

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eggert (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-05-16 eggert StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code