lout-users
[Top][All Lists]
Advanced

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

quick hack in Lout (less hardcoded)


From: Basile STARYNKEVITCH
Subject: quick hack in Lout (less hardcoded)
Date: Wed, 25 Sep 1996 11:22:33 +0200

Hello All,

A sometimes inappropriate feature of Lout is that its many internal
paths are very hard-wired in the binary, so moving the Lout executable
and lib files to another place doesn't work or requires many flags.

I hacked z01.c so that:

if the environment variable LOUTLIB is defined, $LOUTLIB is used
instead of /usr/local/lib/lout/ in hardwired places (so fonts are
looked in $LOUTLIB/fonts, includes are looked in $LOUTLIB/include,
etc).

each individual {fonts hyphens data include} paths can be defaulted by
an appropriate environment variable; for instance, if the environment
varialbe LOUTHYPH is defined, hyphenation are from $LOUTHYPH instead
of /usr/local/lib/lout/hyph/ or $LOUTLIB/hyph/. Likewise for $LOUTFONT
$LOUTDATA $LOUTINCLUDE

I'm enclosing the patch (to lout-3.09, but it probably should work
with lout-3.08) at end of file. it was done thru GNU diff:
diff -U 5 z01.c.orig z01.c

I didn't test the patch (it is trivial, and I don't need it now!) but
did compile it ok!

(patch suggested by  Lionel CHENET)

N.B. Any opinions expressed here are solely mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.

Please cite a *pertinent part* of my mail in all answers
Veuillez citer une *partie pertinente* de mon courrier dans vos reponses



----------------------------------------------------------------------
Basile STARYNKEVITCH   ----  Commissariat à l Energie Atomique 
DRN/DMT/SERMA * CEA/Saclay bat.470 * 91191 GIF/YVETTE CEDEX * France
fax: (33) [1] 69.08.85.68; phone: 69.08.40.66; homephone: 46.65.45.53
email: address@hidden (or else address@hidden);  
I speak french, english, russian. Je parle français, anglais, russe.
----------------------------------------------------------------------

################### start of patch to lout.3.09/z01.c

--- z01.c.orig  Thu Aug 29 14:32:14 1996
+++ z01.c       Wed Sep 25 11:04:16 1996
@@ -205,20 +205,37 @@
   FULL_CHAR *outfile;                  /* name of output file               */
   FILE *out_fp;
   long MemCheckLong;
   FULL_CHAR oname[MAX_BUFF], oval[MAX_BUFF], buff[MAX_BUFF], *p;
   int bp;  OBJECT z;
-
+  char *loutlib = getenv("LOUTLIB");
+  char *loutenv;
+  char loutpath[MAX_BUFF];
   /* set locale if that's what we are doing */
 #if LOCALE_ON
   char catname[MAX_BUFF], *loc;
+  char *locale_dir;
+  char locale_path[MAX_BUFF];
   loc = setlocale(LC_MESSAGES, "");
   if( loc == (char *) NULL )
   { Error(1, 6, "unable to initialize locale", WARN, no_fpos);
     loc = "C";
   }
-  sprintf(catname, "%s/%s/LC_MESSAGES/errors.%s", LOCALE_DIR, loc, loc);
+  /* use LOUTLOCALE env. var if possible */
+  locale_dir = getenv("LOUTLOCALE");
+  /* otherwise, build the locale path from LOUTLIB env. var, ie use
+     $LOUTLIB/locale */
+  if (!locale_dir && loutlib) {
+      locale_path[0]=locale_path[sizeof(locale_path)-1]='\0';
+      strncpy(locale_path, loutlib, sizeof(locale_path)-sizeof("/locale"));
+      strcat(locale_path,"/locale");
+      locale_dir = locale_path;
+  };
+  /* at last, use the wired-in LOCALE_DIR */
+  if (!locale_dir)
+      locale_dir = LOCALE_DIR;
+  sprintf(catname, "%s/%s/LC_MESSAGES/errors.%s", locale_dir, loc, loc);
   MsgCat = catopen(catname, 0);
 #endif
 
   /* initialise various modules, add current directory to search paths */
   BackEnd = POSTSCRIPT;
@@ -562,11 +579,62 @@
     Error(1, 27, "cannot open output file %s", FATAL, no_fpos, outfile);
   FontInit();
   ColourInit();
   LanguageInit();
   PrintInit(out_fp);
-
+  /* if have LOUTLIB env. var or LOUT* env. var use them! */
+  /* fontpath from $LOUTFONT or $LOUTLIB/fonts */
+  loutpath[0]=loutpath[sizeof(loutpath)-1]='\0';
+  if (loutenv=getenv("LOUTFONT"))
+      AddToPath(FONT_PATH,       AsciiToFull(loutenv));
+  if (loutlib) {
+      strncpy(loutpath, loutlib, sizeof(loutpath)-sizeof("/fonts"));
+      strcat(loutpath, "/fonts");
+      AddToPath(FONT_PATH,       AsciiToFull(loutpath));
+  };
+  /* hyphen path from $LOUTHYPH or $LOUTLIB/hyph */
+  loutpath[0]=loutpath[sizeof(loutpath)-1]='\0';
+  if (loutenv=getenv("LOUTHYPH"))
+      AddToPath(HYPH_PATH,       AsciiToFull(loutenv));
+  if (loutlib) {
+      strncpy(loutpath, loutlib, sizeof(loutpath)-sizeof("/hyph"));
+      strcat(loutpath, "/hyph");
+      AddToPath(HYPH_PATH,       AsciiToFull(loutpath));
+  };
+  /* mapping path from $LOUTMAPS or $LOUTLIB/maps */
+  loutpath[0]=loutpath[sizeof(loutpath)-1]='\0';
+  if (loutenv=getenv("LOUTMAPS"))
+      AddToPath(MAPPING_PATH,       AsciiToFull(loutenv));
+  if (loutlib) {
+      strncpy(loutpath, loutlib, sizeof(loutpath)-sizeof("/maps"));
+      strcat(loutpath, "/maps");
+      AddToPath(MAPPING_PATH,       AsciiToFull(loutpath));
+  };
+  /* data path from $LOUTDATA or $LOUTLIB/data */
+  loutpath[0]=loutpath[sizeof(loutpath)-1]='\0';
+  if (loutenv=getenv("LOUTDATA")) {
+      AddToPath(DATABASE_PATH,       AsciiToFull(loutenv));
+      AddToPath(SYSDATABASE_PATH,       AsciiToFull(loutenv));
+  };
+  if (loutlib) {
+      strncpy(loutpath, loutlib, sizeof(loutpath)-sizeof("/data"));
+      strcat(loutpath, "/data");
+      AddToPath(DATABASE_PATH,       AsciiToFull(loutpath));
+      AddToPath(SYSDATABASE_PATH,       AsciiToFull(loutpath));
+  };
+  /* include path from $LOUTINCLUDE or $LOUTLIB/include */
+  loutpath[0]=loutpath[sizeof(loutpath)-1]='\0';
+  if (loutenv=getenv("LOUTINCLUDE")) {
+      AddToPath(INCLUDE_PATH,       AsciiToFull(loutenv));
+      AddToPath(SYSINCLUDE_PATH,       AsciiToFull(loutenv));
+  };
+  if (loutlib) {
+      strncpy(loutpath, loutlib, sizeof(loutpath)-sizeof("/include"));
+      strcat(loutpath, "/include");
+      AddToPath(INCLUDE_PATH,       AsciiToFull(loutpath));
+      AddToPath(SYSINCLUDE_PATH,       AsciiToFull(loutpath));
+  };
   /* append default directories to file search paths */
   AddToPath(FONT_PATH,         AsciiToFull(FONT_DIR));
   AddToPath(HYPH_PATH,         AsciiToFull(HYPH_DIR));
   AddToPath(MAPPING_PATH,      AsciiToFull(MAPS_DIR));
   AddToPath(SYSDATABASE_PATH,  AsciiToFull(DATA_DIR));


#### end of patch to z01.c


reply via email to

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