From jabley@noc.clix.net.nz Sat Oct  2 04:28:01 1999
Return-Path: <jabley@noc.clix.net.nz>
Received: from noc.clix.net.nz (noc.clix.net.nz [203.167.224.28])
	by hub.freebsd.org (Postfix) with ESMTP id EB5E31514F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  2 Oct 1999 04:27:47 -0700 (PDT)
	(envelope-from jabley@noc.clix.net.nz)
Received: (from jabley@localhost)
	by noc.clix.net.nz (8.8.8/8.8.8) id XAA24441;
	Sat, 2 Oct 1999 23:27:46 +1200 (NZST)
	(envelope-from jabley)
Message-Id: <199910021127.XAA24441@noc.clix.net.nz>
Date: Sat, 2 Oct 1999 23:27:46 +1200 (NZST)
From: Joe Abley <jabley@noc.clix.net.nz>
Reply-To: jabley@patho.gen.nz
To: FreeBSD-gnats-submit@freebsd.org
Subject: FICL/softcore.awk patch
X-Send-Pr-Version: 3.2

>Number:         14087
>Category:       kern
>Synopsis:       update sys/boot/ficl/softwords/softcore.awk
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    dcs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct  2 04:30:00 PDT 1999
>Closed-Date:    Fri May 26 16:00:39 PDT 2000
>Last-Modified:  Fri May 26 16:03:09 PDT 2000
>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:
Responsible-Changed-From-To: freebsd-bugs->dcs 
Responsible-Changed-By: dcs 
Responsible-Changed-When: Sat Oct 2 05:34:41 PDT 1999 
Responsible-Changed-Why:  
I asked for it, I got it. :-) 
State-Changed-From-To: open->closed 
State-Changed-By: dcs 
State-Changed-When: Fri May 26 16:00:39 PDT 2000 
State-Changed-Why:  
Kind of committed. It would have helped if a diff against FreeBSD's 
softcore.awk had been provided... the one here seems more like a 
diff against a previous local version. :-) Thanks, anyway. :-) 

>Unformatted:
