These were tiny C tools we had at /bin/c/... that were moved to /bin/s/... when there was a case insensitive fs. Let's move them back to where they always were. We still had them locally at /bin/c, and there are other scripts that might be calling /bin/c. I don't think anyone has scripts calling them at /bin/s. Reference: /n/patches.lsub.org/patch/ctools Date: Mon Apr 23 13:41:40 CES 2012 Signed-off-by: nemo@lsub.org # rm /rc/bin/s --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:07 2011 @@ -0,0 +1,17 @@ +#!/bin/rc + +cat $* | ssam ', x/\n[a-zA-Z0-9_]+\(.*\)\n{\n}\n/ x/\(.*\)/ { + t +1 + +1 a/\n/ + } + , x/\n\(.*\)\n/ { + x/[a-zA-Z0-9_]+[,)]/ { + i/USED(/ + x/,/c/)/ + } + } + , x/\n{\n\(.*\)\n/ x/\(.*/ s/\)/);/g + , x/\n{\n\(.*/ x/\(.*/ y/USED\([a-zA-Z0-9_]*\);/c/\n / + , x/\n{\n\n/c/\n{\n/ + , x/\n \n}\n/c/\n}\n/ + ,p' --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:07 2011 @@ -0,0 +1,21 @@ +#!/bin/rc +# +# check out externs used just in one place; and warn. +# +rfork e + +if(~ $#* 0 1){ + echo usage: $0 files >[1=2] + exit usage +} + +nms=`{ {for(o in $*){ nm $o | grep ' [TDB] ' }} | awk '{print $NF}' | sort -u} + +nm $* >/tmp/nmout +for(n in $nms){ + if(~ `{grep ' '^$n^'$' /tmp/nmout | wc -l} 1) + grep ' '^$n^'$' /tmp/nmout +} +rm /tmp/nmout +exit '' + --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:07 2011 @@ -0,0 +1,22 @@ +#!/bin/rc +# +# check out that we seem to use our globals +# +rfork e + +NOT READY + +if(~ $#* 0 ){ + echo usage: $0 files >[1=2] + exit usage +} + +for(o in $*){ + nms=`{nm $o | grep ' [TDBtdb] ' | awk '{print $NF}'} + for(n in $nms){ + c=`{echo $o | sed 's/\.[0-9]$/.c/'} + grep '(^'^$n^[^a-z0-9A-Z_]')|(^[^a-z0-9A-Z_]'^$n^'[^a-z0-9A-Z_])' $c + } +} +exit '' + --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:08 2011 @@ -0,0 +1,6 @@ +#!/bin/rc + +sed -e 's/^ / case /' \ + -e 's/[ ]=.*,/,/' \ + -e 's/,/:/' \ + -e 's/$/\n break;/' --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Fri Feb 3 11:50:41 2012 @@ -0,0 +1,6 @@ +#!/bin/rc + +cat $* | ssam ', y/.+\n[π∏∆∂A-Za-z0-9_]+\(.*\n/c// ' \ + ', s/\n([π∏∆∂A-Za-z0-9_]+\()/ \1/g' ', p' | \ +grep -v '^static' | grep -v 'threadmain|;' | sed -e 's/$/;/' -e 's/^/extern /' | sort +2 +exit '' --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:08 2011 @@ -0,0 +1,4 @@ +#!/bin/rc +cat $* | sed -e 's/(if|for|while) \(/\1(/' -e 's/\) {/){/' -e 's/} else/}else/' -e 's/else {/else{/' \ + -e 's/enum ?{/enum\n{/' \ + -e 's/^struct ?([^{]+){/struct\n\1 {/' --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Mon May 19 18:17:09 2008 @@ -0,0 +1,3 @@ +#!/bin/rc + +man $* >[2]/dev/null|grep '^ *#include'|sed 's/ *//'|sed 's/[1=2] + exit usage +} + +cs=$* +hdrs=`{grep -h '^#include[ ]*"' $cs | sed 's/#include[ ]*"([^"]+)".*/\1/' | sort -u} + +echo 'HFILES=\' + +all=() +for(h in $hdrs){ + nh=`{grep '^#include[ ]*"'^$h^'"' $cs | wc -l} + if(~ $nh $#cs){ + echo ' '^$h^'\' + all=($all $h) + } +} + +for(c in $cs){ + hs=`{grep -h '^#include[ ]*"' $c | sed 's/#include[ ]*"([^"]+)".*/\1/' } + echo -n `{echo $c | sed 's/\.c$/.$O:/'} + for(h in $hs) + if(! ~ $h $all) + echo -n ' '^$h + echo +} +exit '' --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:09 2011 @@ -0,0 +1,7 @@ +#!/bin/rc + +grep '^struct[ ]+' $* | + sed -e 's/struct[ ]+([∏πa-zA-Z0-9_]+).*/typedef struct \1 \1;/' | + sort -u + + --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:09 2011 @@ -0,0 +1,2 @@ +#!/bin/rc +cat $* | sed 's/[a-z_0-9∏π∂∆]+\(/\n&/' | sed 's/;$/\n{\n}\n/' --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:09 2011 @@ -0,0 +1,3 @@ +#!/bin/rc + +sort -f +1 -2 --- /rc/bin/c Thu Jan 1 00:00:00 1970 +++ /rc/bin/c Wed Sep 28 20:48:09 2011 @@ -0,0 +1,12 @@ +#!/bin/rc +rfork e +tmp=/tmp/rep.$pid +if(~ $#* 0){ + echo usage $0 from to.... + exit usage +} +orig=$1 +shift +cat >$tmp ; for(f in $*) { cat $tmp | sed s/$orig/$"f/g} +rm -f $tmp +exit '' --- /sys/man/1/f2p Thu Apr 12 12:24:55 2012 +++ /sys/man/1/f2p Tue Sep 27 17:03:52 2011 @@ -1,48 +1,48 @@ .TH F2P 1 .SH NAME -argsused, badexterns, badglobals, enum2sw, f2p, ifs, mkdeps, mktypedefs, p2f, psort, rep \- tiny source code tools +argsused, badexterns, badglobals, enum2sw, f2p, ifs, mkdeps, mktypedefs, p2f, psort, rep \- tiny C tools .SH SYNOPSIS -.B s/argsused +.B c/argsused [ .I file ... ] .PP -.B s/badexterns +.B c/badexterns .I files ... .PP -.B s/badglobals +.B c/badglobals .I files ... .PP -.B s/enum2sw +.B c/enum2sw .PP -.B s/f2p +.B c/f2p [ .I file ... ] .PP -.B s/ifs +.B c/ifs [ .I file ... ] .PP -.B s/mkdeps +.B c/mkdeps [ .I file ... ] .PP -.B s/mktypedefs +.B c/mktypedefs [ .I file ... ] .PP -.B s/p2f +.B c/p2f [ .I file ... ] .PP -.B s/psort +.B c/psort .PP -.B s/rep +.B c/rep .I from .I to... .SH DESCRIPTION @@ -52,61 +52,61 @@ Many of them use standard input if no file is given as an argument, and are suitable for use within .IR acme (1). -.TF s/mktypedefs +.TF c/mktypedefs .TP -.B s/argsused +.B c/argsused generates a .I USED(x) sentence for each argument in the functions found in the input files or standard input. .TP -.B s/badexterns +.B c/badexterns receives a series of object files as arguments and locates external symbols used in just one file. Those should perhaps be declared as static symbols. .TP -.B s/badglobals +.B c/badglobals receives a series of object tiles as arguments and locates global symbols that appear to be unused. They could probably go. .TP -.B s/enum2sw +.B c/enum2sw receives as input a declaration of values (e.g., part of declarations within a .IR enum ) and generates a .I switch statement for them. .TP -.B s/f2p +.B c/f2p generates a prototype declaration for each non-static function found in the input. .TP -.B s/p2f +.B c/p2f does the opposite, and writes an empty function definition for each prototype found in the input. .TP -.B s/ifs +.B c/ifs gets rid of spaces that should not be there according to the Plan 9 C style. .TP -.B s/mkdeps +.B c/mkdeps generates dependencies for .I mk (1) according to .I include directives found in the input. .TP -.B s/mktypedefs +.B c/mktypedefs generates .I typedef declarations for each .I struct definition found in the input. .TP -.B s/psort +.B c/psort sorts prototypes by name. .TP -.B s/rep +.B c/rep repeats the text found in the input so that .I from is replaced each time by one of the values given as .I to . .SH SOURCE -.B /rs/bin/s +.B /rc/bin/c .SH BUGS Many. All these tools are tiny shell scripts and do not perform much error checking. Also, they assume code is written using the style of