"Fossies" - the Fresh Open Source Software Archive

Member "s-nail-14.9.19/mk/make-bltin-rc.sh" (26 Apr 2020, 935 Bytes) of package /linux/misc/s-nail-14.9.19.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "make-bltin-rc.sh": 14.9.18_vs_14.9.19.

    1 #!/bin/sh -
    2 #@ Generate builtin RC file (configuration sourced in environment).
    3 #
    4 # Public Domain
    5 
    6 LC_ALL=C
    7 : ${awk:=awk}
    8 
    9 < "$1" > "$2" exec ${awk} '
   10    BEGIN{
   11       lines = 0
   12       dat = ""
   13 
   14       # Sun xpg4/bin/awk expands those twice:
   15       #  Notice that backslash escapes are interpreted twice, once in
   16       #  lexical processing of the string and once in processing the
   17       #  regular expression.
   18       dblexp = "\""
   19       gsub(/"/, "\\\\\"", dblexp)
   20       dblexp = (dblexp == "\134\"")
   21    }
   22 
   23    function quote(s){
   24       gsub("\"", (dblexp ? "\\\\\"" : "\134\""), s)
   25       return s
   26    }
   27 
   28    /^[  ]*#/{next}
   29    /^[  ]*$/{next}
   30    /\\$/{
   31       sub("^[[:space:]]*", "")
   32       sub("\\\\$", "")
   33       dat = dat $0
   34       next
   35    }
   36    {
   37       sub("^[[:space:]]*", "")
   38       print "/*{*/\"" quote(dat $0) "\"/*}*/,"
   39       ++lines;
   40       dat = ""
   41       next
   42    }
   43 
   44    END{print "#define a_GO_BLTIN_RC_LINES_CNT " lines}
   45 '
   46 
   47 # s-sh-mode