Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Oct 1999 23:27:46 +1200 (NZST)
From:      Joe Abley <jabley@noc.clix.net.nz>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/14087: FICL/softcore.awk patch
Message-ID:  <199910021127.XAA24441@noc.clix.net.nz>

next in thread | raw e-mail | index | archive | help

>Number:         14087
>Category:       kern
>Synopsis:       update sys/boot/ficl/softwords/softcore.awk
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct  2 04:30:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Joe Abley
>Release:        current
>Organization:
Global Domination Inc
>Environment:

N/A

>Description:

Update sys/boot/ficl/softwords/softcore.awk in the tree to include
some space optimisation in the ficl keywords stored in the giant C
string softWords[].

Optimisation rules tested to exactly match output of new softcore.pl
supplied by dcs for test data

  cat /sys/boot/ficl/softwords/*.fr

>How-To-Repeat:

N/A

>Fix:
	
Apply the following patch. If symptoms persist, consult a specialist.

*** softcore.awk.orig	Sat Oct  2 23:19:48 1999
--- softcore.awk	Sat Oct  2 23:18:52 1999
***************
*** 1,6 ****
--- 1,15 ----
  #!/usr/bin/awk -f
+ #
  # Convert forth source files to a giant C string
+ #
  # Joe Abley <jabley@patho.gen.nz>, 12 January 1999
+ #
+ # 02-oct-1999:  Cleaned up awk slightly; added some additional logic
+ #               suggested by dcs to compress the stored forth program.
+ #
+ # Note! This script uses strftime() which is a gawk-ism, and the
+ # POSIX [[:space:]] character class.
+ #
  # $FreeBSD: src/sys/boot/ficl/softwords/softcore.awk,v 1.3 1999/09/29 10:58:43 dcs Exp $
  
  BEGIN \
***************
*** 19,60 ****
    printf "** Created automagically by ficl/softwords/softcore.awk\n";
    printf "*/\n\n";
    printf "#include \"ficl.h\"\n\n";
!   printf "static char softWords[] =\n";
  
    commenting = 0;
  }
  
  # some general early substitutions
  {
!   gsub("\t", "    ");			# replace each tab with 4 spaces
!   gsub("\"", "\\\"");			# escape quotes
!   gsub("\\\\[[:space:]]+$", "");	# toss empty comments
! }
! 
! # strip out empty lines
! /^ *$/ \
! {
!   next;
  }
  
  # emit \ ** lines as multi-line C comments
! /^\\[[:space:]]\*\*/ && (commenting == 0) \
  {
!   sub("^\\\\[[:space:]]", "");
!   printf "/*\n%s\n", $0;
    commenting = 1;
    next;
  }
  
! /^\\[[:space:]]\*\*/ \
  {
-   sub("^\\\\[[:space:]]", "");
-   printf "%s\n", $0;
    next;
  }
  
! # if we are in a comment, then close it now (actual meat for this
! # input line processed in later predicates)
  (commenting != 0) \
  {
    commenting = 0;
--- 28,64 ----
    printf "** Created automagically by ficl/softwords/softcore.awk\n";
    printf "*/\n\n";
    printf "#include \"ficl.h\"\n\n";
!   printf "static char softWords[] = \n";
  
    commenting = 0;
  }
  
  # some general early substitutions
  {
!   gsub(/\t/, "    ");			# replace each tab with 4 spaces
!   gsub(/\"/, "\\\"");			# escape quotes
!   gsub(/\\[[:space:]]+$/, "");		# toss empty comments
  }
  
  # emit \ ** lines as multi-line C comments
! /^\\[[:space:]]\*\*/ \
  {
!   sub(/^\\[[:space:]]/, "");
!   if (commenting == 0) printf "/*\n";
!   printf "%s\n", $0;
    commenting = 1;
    next;
  }
  
! # strip blank lines
! /^[[:space:]]*$/ \
  {
    next;
  }
  
! # if we have previously been processing a multi-line comment, then
! # close the comment now (since this line isn't part of a multi-line
! # comment)
  (commenting != 0) \
  {
    commenting = 0;
***************
*** 65,110 ****
  # (supports single-line directives only)
  /^\\[[:space:]]#/ \
  {
!   sub("^\\\\[[:space:]]", "");
    printf "%s\n", $0;
    next;
  }
  
! # toss all other comments
  /^[[:space:]]*\\/ \
  {
    next;
  }
  
! # lop off trailing comments
  /\\[[:space:]]+/ \
  {
!   sub("\\\\[[:space:]]+.*$", "");
  }
  
! # delete ( ) comments
! /[[:space:]]+\([[:space:]].*\)/ \
  {
!   gsub("[[:space:]]+\([[:space:]].*\)", "");
  }
  
  # remove leading spaces
  /^[[:space:]]+/ \
  {
!   sub("^[[:space:]]+", "");
  }
  
  # removing trailing spaces
  /[[:space:]]+$/ \
  {
!   sub("[[:space:]]+$", "");
  }
  
  # emit all other lines as quoted string fragments
  {
!   sub("\\\\[[:space:]]+.*$", "");	# lop off trailing \ comments
!   sub("[[:space:]]+$", "");		# remove trailing spaces
!   printf "    \"%s\"\n", $0;
    next;
  }
  
--- 69,118 ----
  # (supports single-line directives only)
  /^\\[[:space:]]#/ \
  {
!   sub(/^\\[[:space:]]/, "");
    printf "%s\n", $0;
    next;
  }
  
! # toss all other full-line \ comments
  /^[[:space:]]*\\/ \
  {
    next;
  }
  
! # lop off trailing \ comments
  /\\[[:space:]]+/ \
  {
!   sub(/\\[[:space:]]+.*$/, "");
  }
  
! # expunge ( ) comments
! /[[:space:]]+\([[:space:]][^\)]*\)/ \
  {
!   gsub(/[[:space:]]+\([[:space:]][^\)]*\)/, "");
  }
  
  # remove leading spaces
  /^[[:space:]]+/ \
  {
!   sub(/^[[:space:]]+/, "");
  }
  
  # removing trailing spaces
  /[[:space:]]+$/ \
  {
!   sub(/[[:space:]]+$/, "");
! }
! 
! # strip out empty lines again (preceding rules may have generated some)
! /^[[:space:]]*$/ \
! {
!   next;
  }
  
  # emit all other lines as quoted string fragments
  {
!   printf "    \"%s \"\n", $0;
    next;
  }
  

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910021127.XAA24441>