dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: treecc mkskel-sh,NONE,1.1 .cvsignore,1.2,1.3


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: treecc mkskel-sh,NONE,1.1 .cvsignore,1.2,1.3 ChangeLog,1.54,1.55 Makefile.am,1.2,1.3 info.h,1.5,1.6 main.c,1.2,1.3 skeleton.c,1.3,1.4
Date: Sat, 14 Dec 2002 23:03:29 -0500

Update of /cvsroot/dotgnu-pnet/treecc
In directory subversions:/tmp/cvs-serv24877

Modified Files:
        .cvsignore ChangeLog Makefile.am info.h main.c skeleton.c 
Added Files:
        mkskel-sh 
Log Message:


Bind the skeleton files into the "treecc" binary so that we don't have
any more skeleton path search problems.


--- NEW FILE ---
#!/bin/sh
#
# mkskel-sh - Make a .c file corresponding to a set of skeleton files.
#
# Usage: mkskel-sh etc/FILE ... >OUT
#
# Copyright (C) 2002  Southern Storm Software, Pty Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Check the command-line parameters.
if test -z "$1" ; then
        echo "Usage: $0 etc/FILE ... >OUT"
        exit 1
fi

# Output the header material.
echo '/* This file is automatically generated by mkskel-sh - do not edit */'
echo ''
echo '#include "config.h"'
echo ''

# Convert the input files into strings.
for file in $* ; do
        VARNAME=TreeCCSkel_`basename "$file" | sed -e '1,$s/\./_/g'`
        echo "static char const ${VARNAME}[] ="
        sed -e '1,$s/\\/\\\\/g' "$file" | \
                sed -e '1,$s/"/\\"/g' | \
                sed -e '1,$s/^/"/g' | \
                sed -e '1,$s/$/\\n"/g'
        echo ';'
done

# Output the skeleton lookup table.
echo 'const char * const TreeCCSkelFiles[] = {'
for file in $* ; do
        BASENAME=`basename "$file"`
        VARNAME=TreeCCSkel_`basename "$file" | sed -e '1,$s/\./_/g'`
        echo '    "'"$BASENAME"'", '"$VARNAME"','
done
echo '    0'
echo '};'

# Output the footer material and exit.
exit 0

Index: .cvsignore
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** .cvsignore  15 Aug 2002 23:28:04 -0000      1.2
--- .cvsignore  15 Dec 2002 04:03:26 -0000      1.3
***************
*** 11,12 ****
--- 11,13 ----
  aclocal.m4
  config.h.in
+ skels.c

Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/ChangeLog,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -r1.54 -r1.55
*** ChangeLog   23 Nov 2002 19:48:29 -0000      1.54
--- ChangeLog   15 Dec 2002 04:03:27 -0000      1.55
***************
*** 1,3 ****
--- 1,14 ----
  
+ 2002-12-15  Rhys Weatherley  <address@hidden>
+ 
+       * mkskel-sh, .cvsignore, Makefile.am, info.h, main.c, skeleton.c,
+       doc/treecc.1, doc/treecc.texi, etc/Makefile.am, tests/output1.out,
+       tests/output12.out, tests/output13.out, tests/output14.out,
+       tests/output15.out, tests/output2.out, tests/output3.out,
+       tests/output4.out, tests/output5.out, tests/output6.out,
+       tests/output7.out, tests/output8.out, tests/output9.out,
+       tests/test_output.c: bind the skeleton files into the "treecc"
+       binary so that we don't have any more skeleton path search problems.
+ 
  2002-11-24  Gopal V  <address@hidden>
        

Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Makefile.am 2 Nov 2002 04:38:21 -0000       1.2
--- Makefile.am 15 Dec 2002 04:03:27 -0000      1.3
***************
*** 22,27 ****
--- 22,36 ----
                                      parse.c \
                                          skeleton.c \
+                                         skels.c \
                                          stream.c
  
+ SKELETON_FILES = $(top_srcdir)/etc/c_skel.c \
+                                $(top_srcdir)/etc/c_skel.h \
+                                $(top_srcdir)/etc/cpp_skel.cc \
+                                $(top_srcdir)/etc/cpp_skel.h
+ 
+ $(srcdir)/skels.c: $(SKELETON_FILES) $(top_srcdir)/mkskel-sh
+       $(SHELL) $(top_srcdir)/mkskel-sh $(SKELETON_FILES) >$(srcdir)/skels.c
+ 
  if USINGGCC
  INCLUDES = -Wall -DTREECC_DATA_DIR=\"$(datadir)/treecc\"
***************
*** 29,30 ****
--- 38,41 ----
  INCLUDES = -DTREECC_DATA_DIR=\"$(datadir)/treecc\"
  endif
+ 
+ CLEANFILES = skels.c

Index: info.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/info.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** info.h      2 Nov 2002 04:38:21 -0000       1.5
--- info.h      15 Dec 2002 04:03:27 -0000      1.6
***************
*** 243,249 ****
        int                             block_size;
  
-       /* Directory in which to look for skeleton files */
-       char               *skeletonDirectory;
- 
        /* Name of the directory to output Java source files to */
        char               *outputDirectory;
--- 243,246 ----

Index: main.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** main.c      16 Dec 2001 05:30:06 -0000      1.2
--- main.c      15 Dec 2002 04:03:27 -0000      1.3
***************
*** 2,6 ****
   * main.c - Main program entry point for "treecc".
   *
!  * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * main.c - Main program entry point for "treecc".
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 39,43 ****
        char *extension = "c";
        char *outputDir = NULL;
-       char *skeletonDir = NULL;
        int forceCreate = 0;
        TreeCCInput input;
--- 39,42 ----
***************
*** 101,104 ****
--- 100,105 ----
                        else if(!strcmp(argv[1], "--skeleton-dir"))
                        {
+                               /* This option is obsolete: we still parse it 
just in
+                                  case there are older build systems that 
expect it */
                                --argc;
                                ++argv;
***************
*** 108,112 ****
                                        return 1;
                                }
-                               skeletonDir = argv[1];
                        }
                        else if(!strcmp(argv[1], "--extension"))
--- 109,112 ----
***************
*** 218,224 ****
                                        case 's':
                                        {
                                                if(*opt != '\0')
                                                {
-                                                       skeletonDir = opt;
                                                        opt = "";
                                                }
--- 218,225 ----
                                        case 's':
                                        {
+                                               /* This option is obsolete: we 
still parse it just in
+                                                  case there are older build 
systems that expect it */
                                                if(*opt != '\0')
                                                {
                                                        opt = "";
                                                }
***************
*** 232,236 ****
                                                        --argc;
                                                        ++argv;
-                                                       skeletonDir = argv[1];
                                                }
                                        }
--- 233,236 ----
***************
*** 344,348 ****
        context->force = forceCreate;
        context->outputDirectory = outputDir;
-       context->skeletonDirectory = skeletonDir;
  
        /* Create the default source and header streams */
--- 344,347 ----
***************
*** 423,427 ****
  {
        fprintf(stderr, "TREECC " VERSION " - Tree Compiler-Compiler\n");
!       fprintf(stderr, "Copyright (c) 2001 Southern Storm Software, Pty 
Ltd.\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "Usage: %s [options] input ...\n", progname);
--- 422,426 ----
  {
        fprintf(stderr, "TREECC " VERSION " - Tree Compiler-Compiler\n");
!       fprintf(stderr, "Copyright (c) 2001, 2002 Southern Storm Software, Pty 
Ltd.\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "Usage: %s [options] input ...\n", progname);
***************
*** 433,438 ****
        fprintf(stderr, "    -d dir,  --output-dir file\n");
        fprintf(stderr, "        Set the name of the Java output directory.\n");
-       fprintf(stderr, "    -s dir,  --skeleton-dir file\n");
-       fprintf(stderr, "        Set the name of the skeleton directory.\n");
        fprintf(stderr, "    -e ext,  --extension ext\n");
        fprintf(stderr, "        Set the output file extension (default is 
\".c\").\n");
--- 432,435 ----
***************
*** 448,452 ****
  {
        printf("TREECC " VERSION " - Tree Compiler-Compiler\n");
!       printf("Copyright (c) 2001 Southern Storm Software, Pty Ltd.\n");
        printf("\n");
        printf("TREECC comes with ABSOLUTELY NO WARRANTY.  This is free 
software,\n");
--- 445,449 ----
  {
        printf("TREECC " VERSION " - Tree Compiler-Compiler\n");
!       printf("Copyright (c) 2001, 2002 Southern Storm Software, Pty Ltd.\n");
        printf("\n");
        printf("TREECC comes with ABSOLUTELY NO WARRANTY.  This is free 
software,\n");

Index: skeleton.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/skeleton.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** skeleton.c  17 Mar 2002 10:35:28 -0000      1.3
--- skeleton.c  15 Dec 2002 04:03:27 -0000      1.4
***************
*** 23,38 ****
  #include "info.h"
  #include "errors.h"
- #if HAVE_UNISTD_H
-       #include <unistd.h>
- #endif
- #if HAVE_SYS_TYPES_H
-       #include <sys/types.h>
- #endif
- #if HAVE_SYS_STAT_H
-       #include <sys/stat.h>
- #endif
- #if defined(WIN32) || defined(_WIN32)
-       #include <windows.h>
- #endif
  
  #ifdef        __cplusplus
--- 23,26 ----
***************
*** 41,187 ****
  
  /*
!  * Check for a skeleton file in a specific directory.
!  * Returns the malloc'ed path if found, or NULL otherwise.
   */
! static char *CheckSkeleton(const char *dir, const char *skeleton)
  {
!       int len;
!       char *path;
! 
!       /* Construct the full skeleton path */
!       len = strlen(dir);
!       if((path = (char *)malloc(len + strlen(skeleton) + 2)) == 0)
!       {
!               TreeCCOutOfMemory(0);
!       }
!       strcpy(path, dir);
! #if (defined(WIN32) || defined(_WIN32)) && !defined(__CYGWIN__)
!       path[len] = '\\';
! #else
!       path[len] = '/';
! #endif
!       strcpy(path + len + 1, skeleton);
! 
!       /* Is the file present? */
! #if HAVE_ACCESS
!       if(access(path, 0) == 0)
!       {
!               return path;
!       }
! #else
! #if HAVE_STAT
        {
!               struct stat st;
!               if(stat(path, &st) == 0)
                {
!                       return path;
                }
        }
- #else
-       {
-               /* Don't have "access" or "stat", so try to open it */
-               FILE *file = fopen(path, "r");
-               if(file)
-               {
-                       fclose(file);
-                       return path;
-               }
-       }
- #endif
- #endif
- 
-       /* Could not find the skeleton file */
-       free(path);
        return 0;
  }
  
  /*
!  * Find a skeleton file along the standard search path.
!  * Returns the malloc'ed path if found, or NULL otherwise.
   */
! static char *FindSkeleton(TreeCCContext *context, const char *skeleton)
  {
!       char *path;
! 
!       /* Look in the user-supplied skeleton directory */
!       if(context->skeletonDirectory)
        {
!               if((path = CheckSkeleton(context->skeletonDirectory, skeleton)) 
!= 0)
!               {
!                       return path;
!               }
        }
! 
!       /* Look in Windows-specific locations */
! #if defined(WIN32) || defined(_WIN32)
        {
!               char moduleName[1024];
!               int len;
! 
!               if(GetModuleFileName(NULL, moduleName, sizeof(moduleName) - 8) 
!= 0)
                {
!                       /* Trim the module name to the name of the directory */
!                       len = strlen(moduleName);
!                       while(len > 0 && moduleName[len - 1] != '\\' &&
!                                 moduleName[len - 1] != '/' &&
!                                 moduleName[len - 1] != ':')
!                       {
!                               --len;
!                       }
!                       if(len > 0 && moduleName[len - 1] != ':')
!                       {
!                               --len;
!                       }
!                       if(len > 0)
!                       {
!                               /* Look in the "etc" sub-directory underneath 
where the
!                                  executable was loaded from */
!                               strcpy(moduleName + len, "\\etc");
!                               if((path = CheckSkeleton(moduleName, skeleton)) 
!= 0)
!                               {
!                                       return path;
!                               }
! 
!                               /* Look in the same directory as the executable 
*/
!                               moduleName[len] = '\0';
!                               if((path = CheckSkeleton(moduleName, skeleton)) 
!= 0)
!                               {
!                                       return path;
!                               }
!                       }
                }
        }
! #endif
! 
! #if !(defined(WIN32) || defined(_WIN32)) || defined(__CYGWIN__)
! 
!       /* Try looking in the compiled-in default directory */
! #ifdef TREECC_DATA_DIR
!       if((path = CheckSkeleton(TREECC_DATA_DIR, skeleton)) != 0)
        {
!               return path;
        }
! #endif
! 
!       /* Look in several standard places that it might be */
!       if((path = CheckSkeleton("/usr/local/share/treecc", skeleton)) != 0)
!       {
!               return path;
!       }
!       if((path = CheckSkeleton("/opt/local/share/treecc", skeleton)) != 0)
!       {
!               return path;
!       }
!       if((path = CheckSkeleton("/usr/share/treecc", skeleton)) != 0)
!       {
!               return path;
!       }
! #endif
! 
!       /* Could not find the skeleton */
!       TreeCCAbort(0, "could not locate the skeleton file \"%s\"\n", skeleton);
! 
!       /* Keep the compiler happy */
!       return (char *)0;
  }
  
--- 29,75 ----
  
  /*
!  * Find a particular skeleton string within "skels.c".
   */
! extern const char * const TreeCCSkelFiles[];
! static char *FindSkeletonString(const char *skeleton)
  {
!       char **search = (char **)TreeCCSkelFiles;
!       while(*search != 0)
        {
!               if(!strcmp(*search, skeleton))
                {
!                       return search[1];
                }
+               search += 2;
        }
        return 0;
  }
  
  /*
!  * Read a line from a skeleton buffer..
   */
! static int ReadSkeletonLine(char *buffer, int size, char **skel)
  {
!       char *ptr = *skel;
!       if(*ptr == '\0')
        {
!               return 0;
        }
!       while(*ptr != '\0' && *ptr != '\n')
        {
!               if(size > 2)
                {
!                       *buffer++ = *ptr;
!                       --size;
                }
+               ++ptr;
        }
!       if(*ptr == '\n')
        {
!               *buffer++ = *ptr++;
        }
!       *buffer = '\0';
!       *skel = ptr;
!       return 1;
  }
  
***************
*** 189,203 ****
                                                   const char *skeleton)
  {
!       char *path = FindSkeleton(context, skeleton);
!       FILE *file = fopen(path, "r");
        char buffer[BUFSIZ];
        int posn, start;
!       if(!file)
        {
!               perror(path);
                exit(1);
        }
!       TreeCCStreamLine(stream, 1, path);
!       while(fgets(buffer, BUFSIZ, file))
        {
        #if HAVE_STRCHR
--- 77,92 ----
                                                   const char *skeleton)
  {
!       char *skelstr = FindSkeletonString(skeleton);
        char buffer[BUFSIZ];
        int posn, start;
!       if(!skelstr)
        {
!               fprintf(stderr,
!                               "treecc: internal error - could not find 
skeleton \"%s\"\n",
!                               skeleton);
                exit(1);
        }
!       TreeCCStreamLine(stream, 1, skeleton);
!       while(ReadSkeletonLine(buffer, BUFSIZ, &skelstr))
        {
        #if HAVE_STRCHR
***************
*** 251,257 ****
        #endif
        }
-       fclose(file);
        TreeCCStreamFixLine(stream);
-       free(path);
  }
  
--- 140,144 ----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]