home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume15 / dmake-3.6 / part20 < prev    next >
Text File  |  1990-10-14  |  41KB  |  1,286 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: dvadura@watdragon.waterloo.edu
  3. subject: v15i072: dmake version 3.6 (part 20/25)
  4. from: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 15, Issue 72
  8. Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  9. Archive-name: dmake-3.6/part20
  10.  
  11. #!/bin/sh
  12. # this is part 20 of a multipart archive
  13. # do not concatenate these parts, unpack them in order with /bin/sh
  14. # file infer.c continued
  15. #
  16. CurArch=20
  17. if test ! -r s2_seq_.tmp
  18. then echo "Please unpack part 1 first!"
  19.      exit 1; fi
  20. ( read Scheck
  21.   if test "$Scheck" != $CurArch
  22.   then echo "Please unpack part $Scheck next!"
  23.        exit 1;
  24.   else exit 0; fi
  25. ) < s2_seq_.tmp || exit 1
  26. echo "x - Continuing file infer.c"
  27. sed 's/^X//' << 'SHAR_EOF' >> infer.c
  28. X        * and we should Define it and attach it to the CELL pointed at
  29. X        * by cp.  This recursive inference is performed only if
  30. X        * Transitive closure is enabled.
  31. X        */
  32. X           if( _trans ) {
  33. X          int _save = _dmax;
  34. X          if( !_dmax ) _dmax += _dmax_fix;
  35. X          infcell = Infer_recipe( &iprq, iprq.CE_HOW, &top_dfa_stack,
  36. X                      sdir);
  37. X          _dmax = _save;
  38. X
  39. X          if( infcell != NIL(CELL) ) {
  40. X             /* We found we can make the prerequisite, so make it into
  41. X              * a real node.  This means, mark it for possible
  42. X              * removal, and when you make it into a node make sure
  43. X              * you don't clobber the Def_cell name.
  44. X              */
  45. X             infcell  = Def_cell( iprqh.ht_name, setdirroot );
  46. X             thp      = infcell->ce_name;
  47. X             *infcell = iprq;
  48. X             infcell->ce_name = thp;
  49. X             infcell->ce_flag |= F_REMOVE;
  50. X              }
  51. X           }
  52. X
  53. X        /* If we pushed a directory for the inferred prerequisite then
  54. X         * pop it.
  55. X         */
  56. X        if( ipush ) Pop_dir(FALSE);
  57. X
  58. Xtry_next_edge:
  59. X        FREE( iprqh.ht_name );
  60. X     }
  61. X
  62. X     edge = edge->ed_next;
  63. X      }
  64. X      while( infcell == NIL(CELL) && edge != meta->CE_EDGES );
  65. X
  66. X
  67. X      /* If none of the previous edges were any good, and there was an
  68. X       * edge with no prerequsite, then use it.
  69. X       */
  70. X      if( infcell == NIL(CELL) ) 
  71. X         if( edge_noprq != NIL(EDGE) ) 
  72. X        pedge = edge_noprq;
  73. X     else
  74. X        pedge = NIL(EDGE);
  75. X      else {
  76. X     /* We have a match, so make the edge's pointer for the corresponding
  77. X      * %-meta target point at the matched prerequisite so that the next
  78. X      * time we perform an inference we will check this edge first.
  79. X      */
  80. X         meta->CE_EDGES = pedge;
  81. X     if( !_trans ) infcell->ce_attr |= A_NOINFER;
  82. X      }
  83. X
  84. X
  85. X      /* If we pushed a dir when we treated this %-meta, then
  86. X       * pop it.
  87. X       */
  88. X      if( push ) Pop_dir(FALSE);
  89. X
  90. X
  91. X      /* Need this so that pdfa does not get advanced, and remains pointing
  92. X       * to the dfa, that just resulted in a successful match.
  93. X       */
  94. X      if( pedge != NIL(EDGE) ) break;
  95. X   }
  96. X
  97. X
  98. X   /* If pedge is not NIL then we have found an edge and possibly inferred
  99. X    * a prerequisite.  In any case we should definitely attach the recipe to
  100. X    * the HOW node of the cell pointed at by cp.  If the CELL has no HOW node
  101. X    * the we allocate one.
  102. X    */
  103. X   if( pedge != NIL(EDGE) ) {
  104. X      LINKPTR lp;
  105. X      HOWPTR  nhow, ihow;
  106. X
  107. X      DB_PRINT("inf", ("taking edge [%s] to [%s]", pedge->ed_tg->CE_NAME,
  108. X           (pedge->ed_prq == NIL(CELL)) ? "(none)":pedge->ed_prq->CE_NAME));
  109. X
  110. X      if( Verbose )
  111. X     printf("%s:  Inferred recipe using edge from [%s] to [%s]\n",
  112. X        Pname, pedge->ed_tg->CE_NAME,
  113. X        (pedge->ed_prq == NIL(CELL)) ? "(none)":pedge->ed_prq->CE_NAME);
  114. X
  115. X      if( how == NIL(HOW) ) {
  116. X         /* Get a new HOW node, this should happen only for inferred
  117. X      * cells, as such they have no prior HOW node */
  118. X         TALLOC( how, 1, HOW );
  119. X     cp->CE_HOW = how;
  120. X      }
  121. X      
  122. X
  123. X      /* Attach the recipe to the HOW node.  Note that if the %-meta recipe
  124. X       * is a :: recipe then we will attach all of the HOW cells belonging to
  125. X       * the %-meta :: rule that we matched to the CELL, and we will place
  126. X       * them so that they preceed subsequent HOW cells in the list.  Under
  127. X       * these circumstances the CELL is marked as a MULTI cell.
  128. X       */
  129. X      nhow = how->hw_next;
  130. X      for( ihow=meta->CE_EDGES->ed_how; ihow != NIL(HOW); ihow=ihow->hw_next ) {
  131. X     how->hw_per     = pdfa->dl_per;
  132. X     how->hw_flag   |= (ihow->hw_flag & (F_SINGLE | F_GROUP)) | F_INFER;
  133. X     how->hw_attr   |= (ihow->hw_attr & A_TRANSFER);
  134. X     how->hw_recipe  = ihow->hw_recipe;
  135. X
  136. X     /* Add global prerequisites to the first HOW cell
  137. X      */
  138. X     for( lp=ihow->hw_indprq; lp != NIL(LINK); lp=lp->cl_next ) {
  139. X        char    *name = lp->cl_prq->CE_NAME;
  140. X        CELLPTR tcp;
  141. X
  142. X        name = _build_name( cp->CE_NAME, name, pdfa->dl_per );
  143. X        tcp  = Def_cell( name, setdirroot );
  144. X        tcp->ce_flag |= F_REMOVE;
  145. X        Add_prerequisite( how, tcp, FALSE );
  146. X
  147. X        if( Verbose )
  148. X           printf( "%s:  Inferred indirect prerequisite [%s]\n",
  149. X                   Pname, name );
  150. X        FREE(name);
  151. X     }
  152. X
  153. X     /* If infcell is not NIL then we have inferred a prerequisite, so
  154. X      * add it to the first HOW cell as well.
  155. X      */
  156. X     if( infcell != NIL(CELL) ) {
  157. X        (Add_prerequisite( how, infcell, FALSE))->cl_flag |= F_TARGET;
  158. X
  159. X        if( Verbose )
  160. X           printf( "%s:  Inferred prerequisite [%s]\n",
  161. X                   Pname, infcell->CE_NAME );
  162. X     }
  163. X
  164. X     /* If the recipe is a :: recipe then Insert a new HOW node after
  165. X      * the inferred recipe HOW node and prior to any previous
  166. X      * :: nodes.
  167. X      */
  168. X     if( ihow->hw_next != NIL(HOW) ) {
  169. X        cp->ce_flag |= F_MULTI;
  170. X        TALLOC( how->hw_next, 1, HOW );
  171. X        how = how->hw_next;
  172. X     }
  173. X      }
  174. X      how->hw_next = nhow;
  175. X      pdfa->dl_per = NIL(char);        /* We used it, so don't FREE it */
  176. X
  177. X      /* Make sure to set the FLAGS, and ATTRIBUTES of the CELL so that it
  178. X       * gets made correctly.
  179. X       */
  180. X      cp->ce_flag |= F_RULES | F_TARGET | F_INFER;
  181. X
  182. X      if( !(cp->ce_attr & A_SETDIR) ) {
  183. X         cp->ce_attr |= (meta->ce_attr & A_SETDIR);
  184. X     cp->ce_dir   = meta->ce_dir;
  185. X      }
  186. X   }
  187. X   else
  188. X      cp = NIL(CELL);
  189. X
  190. X   _free_dfas( dfas );
  191. X
  192. X   DB_PRINT( "mem", ("%s:-< mem %ld", (cp!=NIL(CELL)) ? cp->CE_NAME : "(none)",
  193. X         (long)coreleft()));
  194. X   DB_PRINT( "inf", ("<<< Exit, cp = %04x", cp) );
  195. X   DB_RETURN( cp );
  196. X}
  197. X
  198. X
  199. Xstatic char *
  200. X_build_name( tg, meta, per )
  201. Xchar *tg;
  202. Xchar *meta;
  203. Xchar *per;
  204. X{
  205. X   char    *name;
  206. X
  207. X   name = Apply_edit( meta, "%", per, FALSE, FALSE );
  208. X   if( strchr(name, '$') ) {
  209. X      HASHPTR m_at;
  210. X      char *tmp;
  211. X
  212. X      m_at = Def_macro( "@", tg, M_MULTI );
  213. X      tmp = Expand( name );
  214. X
  215. X      if( m_at->ht_value != NIL(char) ) {
  216. X     FREE( m_at->ht_value );
  217. X     m_at->ht_value = NIL(char);
  218. X      }
  219. X
  220. X      if( name != meta ) FREE( name );
  221. X      name = tmp;
  222. X   }
  223. X   else if( name == meta )
  224. X      name = _strdup( name );
  225. X
  226. X   return(name);
  227. X}
  228. X
  229. X
  230. Xstatic DFALINKPTR
  231. X_dfa_subset( pdfa, stack )/*
  232. X============================
  233. X   This is the valid DFA subset computation.  Whenever a CELL has a Match_dfa
  234. X   subset computed this algorithm is run to see if any of the previously
  235. X   computed sets on the DFA stack are proper subsets of the new set.  If they
  236. X   are, then any elements of the matching subset whose Prep counts exceed
  237. X   the allowed maximum given by Prep are removed from the computed DFA set,
  238. X   and hence from consideration, thereby cutting off the cycle in the
  239. X   inference graph. */
  240. XDFALINKPTR       pdfa;
  241. Xregister DFASETPTR stack;
  242. X{
  243. X   register DFALINKPTR element;
  244. X   DFALINKPTR          nelement;
  245. X
  246. X   DB_ENTER( "_dfa_subset" );
  247. X
  248. X   for(; pdfa != NIL(DFALINK) && stack != NIL(DFASET); stack = stack->df_next) {
  249. X      int subset = TRUE;
  250. X
  251. X      for( element=stack->df_set; subset && element != NIL(DFALINK);
  252. X           element=element->dl_next ) {
  253. X         register DFALINKPTR subel;
  254. X
  255. X     for( subel = pdfa;
  256. X          subel != NIL(DFALINK) && (subel->dl_meta != element->dl_meta);
  257. X          subel = subel->dl_next );
  258. X
  259. X     if( subset = (subel != NIL(DFALINK)) ) element->dl_member = subel;
  260. X      }
  261. X
  262. X      if( subset )
  263. X     for( element=stack->df_set; element != NIL(DFALINK);
  264. X          element=element->dl_next ) {
  265. X        DFALINKPTR mem = element->dl_member;
  266. X        int        npr = element->dl_prep + 1;
  267. X
  268. X        if( npr > _prep )
  269. X           mem->dl_delete++;
  270. X        else
  271. X           mem->dl_prep = npr;
  272. X     }
  273. X   }
  274. X
  275. X   for( element = pdfa; element != NIL(DFALINK); element = nelement ) {
  276. X      nelement = element->dl_next;
  277. X
  278. X      if( element->dl_delete ) {
  279. X     /* A member of the subset has a PREP count equal to PREP, so
  280. X      * it should not be considered further in the inference, hence
  281. X      * we remove it from the doubly linked set list */
  282. X     if( element == pdfa )
  283. X        pdfa = element->dl_next;
  284. X     else
  285. X        element->dl_prev->dl_next = element->dl_next;
  286. X
  287. X     if( element->dl_next != NIL(DFALINK) )
  288. X        element->dl_next->dl_prev = element->dl_prev;
  289. X
  290. X     DB_PRINT("inf", ("deleting dfa [%s]", element->dl_meta->CE_NAME));
  291. X     FREE( element->dl_per );
  292. X     FREE( element );
  293. X      }
  294. X   }
  295. X
  296. X   DB_RETURN( pdfa );
  297. X}
  298. X
  299. X
  300. X
  301. Xstatic void
  302. X_free_dfas( chain )/*
  303. X=====================
  304. X   Free the list of DFA's constructed by Match_dfa, and linked together by
  305. X   LINK cells.  FREE the % value as well, as long as it isn't NIL. */
  306. XDFALINKPTR chain;
  307. X{
  308. X   register DFALINKPTR tl;
  309. X
  310. X   DB_ENTER( "_free_dfas" );
  311. X
  312. X   for( tl=chain; tl != NIL(DFALINK); chain = tl ) {
  313. X      tl = tl->dl_next;
  314. X
  315. X      DB_PRINT( "inf", ("Freeing DFA [%s], %% = [%s]", chain->dl_meta->CE_NAME,
  316. X                chain->dl_per) );
  317. X
  318. X      if( chain->dl_per != NIL(char) ) FREE( chain->dl_per );
  319. X      FREE( chain );
  320. X   }
  321. X
  322. X   DB_VOID_RETURN;
  323. X}
  324. X
  325. X
  326. Xstatic int
  327. X_count_dots( name )/*
  328. X=====================*/
  329. Xchar *name;
  330. X{
  331. X   register char *p;
  332. X   register int  i = 0;
  333. X
  334. X   for( p = name; *p; p++ ) if(*p == '.') i++;
  335. X
  336. X   return( i );
  337. X}
  338. SHAR_EOF
  339. echo "File infer.c is complete"
  340. chmod 0440 infer.c || echo "restore of infer.c fails"
  341. echo "x - extracting imacs.c (Text)"
  342. sed 's/^X//' << 'SHAR_EOF' > imacs.c &&
  343. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/imacs.c,v 1.1 90/10/06 12:03:48 dvadura Exp $
  344. X-- SYNOPSIS -- define default internal macros.
  345. X-- 
  346. X-- DESCRIPTION
  347. X--    This file adds to the internal macro tables the set of default
  348. X--    internal macros, and for those that are accessible internally via
  349. X--    variables creates these variables, and initializes them to point
  350. X--    at the default values of these macros.
  351. X--
  352. X-- AUTHOR
  353. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  354. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  355. X--
  356. X-- COPYRIGHT
  357. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  358. X-- 
  359. X--      This program is free software; you can redistribute it and/or
  360. X--      modify it under the terms of the GNU General Public License
  361. X--      (version 1), as published by the Free Software Foundation, and
  362. X--      found in the file 'LICENSE' included with this distribution.
  363. X-- 
  364. X--      This program is distributed in the hope that it will be useful,
  365. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  366. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  367. X--      GNU General Public License for more details.
  368. X-- 
  369. X--      You should have received a copy of the GNU General Public License
  370. X--      along with this program;  if not, write to the Free Software
  371. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  372. X--
  373. X-- LOG
  374. X--     $Log:    imacs.c,v $
  375. X * Revision 1.1  90/10/06  12:03:48  dvadura
  376. X * dmake Release, Version 3.6
  377. X * 
  378. X*/
  379. X
  380. X#include "extern.h"
  381. X
  382. Xstatic    void    _set_int_var ANSI((char *, char *, int, int *));
  383. Xstatic    void    _set_string_var ANSI((char *, char *, int, char **));
  384. Xstatic    void    _set_bit_var ANSI((char *, char *, int));
  385. X
  386. X/*
  387. X** Arrange to parse the strings stored in Rules[]
  388. X*/
  389. Xvoid
  390. XMake_rules()
  391. X{
  392. X   Parse(NIL(FILE));
  393. X}
  394. X
  395. X
  396. X#define M_FLAG   M_DEFAULT | M_EXPANDED
  397. X
  398. X/*
  399. X** Add to the macro table all of the internal macro variables plus
  400. X** create secondary variables which will give access to their values
  401. X** easily, both when needed and when the macro value is modified.
  402. X** The latter is accomplished by providing a flag in the macro and a field
  403. X** which gives a pointer to the value if it is a char or string macro value
  404. X** and a mask representing the bit of the global flag register that is affected
  405. X** by this macro's value.
  406. X*/
  407. Xvoid
  408. XCreate_macro_vars()
  409. X{
  410. X   static char* switchar;
  411. X   char   swchar[2];
  412. X
  413. X   swchar[0] = Get_switch_char(), swchar[1] = '\0';
  414. X   _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
  415. X   _set_string_var("DIRSEPSTR", "/", M_PRECIOUS, &DirSepStr);
  416. X   _set_string_var("DIRBRKSTR", DirBrkStr, M_PRECIOUS, &DirBrkStr);
  417. X   
  418. X   _set_bit_var(".SILENT",   "", A_SILENT  );
  419. X   _set_bit_var(".IGNORE",   "", A_IGNORE  );
  420. X   _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
  421. X   _set_bit_var(".EPILOG",   "", A_EPILOG  );
  422. X   _set_bit_var(".PROLOG",   "", A_PROLOG  );
  423. X   _set_bit_var(".NOINFER",  "", A_NOINFER );
  424. X   _set_bit_var(".SEQUENTIAL","",A_SEQ     );
  425. X   _set_bit_var(".USESHELL", "", A_SHELL   );
  426. X   _set_bit_var(".SWAP",     "", A_SWAP    );
  427. X   _set_bit_var(".MKSARGS",  "", A_MKSARGS );
  428. X
  429. X   Glob_attr    = A_DEFAULT;        /* set all flags to NULL   */
  430. X   
  431. X   _set_string_var("SHELL",        "",  M_DEFAULT, &Shell       );
  432. X   _set_string_var("SHELLFLAGS",   " ", M_DEFAULT, &Shell_flags );
  433. X   _set_string_var("GROUPSHELL",   "",  M_DEFAULT, &GShell      );
  434. X   _set_string_var("GROUPFLAGS",   " ", M_DEFAULT, &GShell_flags);
  435. X   _set_string_var("SHELLMETAS",   "",  M_DEFAULT, &Shell_metas );
  436. X   _set_string_var("GROUPSUFFIX",  "",  M_DEFAULT, &Grp_suff    );
  437. X   _set_string_var("PREP",         "0", M_DEFAULT, &Prep        );
  438. X   _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake     );
  439. X
  440. X   _set_string_var("MAKEDIR", Get_current_dir(), M_PRECIOUS|M_NOEXPORT,
  441. X         &Makedir);
  442. X   _set_string_var("PWD",  Makedir, M_DEFAULT|M_NOEXPORT, &Pwd);
  443. X
  444. X   Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
  445. X   _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
  446. X   (void) Def_macro("MAXLINELENGTH", "0", M_FLAG | M_DEFAULT);
  447. X
  448. X   /* set MAXPROCESSLIMIT high initially so that it allows MAXPROCESS to
  449. X    * change from command line. */
  450. X   _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT, &Max_proclmt );
  451. X   _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
  452. X}
  453. X
  454. X/*
  455. X** Define a string variable value, and set up the macro.
  456. X*/
  457. Xstatic void
  458. X_set_int_var(name, val, flag, var)
  459. Xchar *name;
  460. Xchar *val;
  461. Xint  flag;
  462. Xint  *var;
  463. X{
  464. X   HASHPTR hp;
  465. X
  466. X   hp = Def_macro(name, val, M_FLAG | flag);
  467. X   hp->ht_flag |= M_VAR_INT | M_MULTI;
  468. X   hp->MV_IVAR  = var;
  469. X   *var         = atoi(val);
  470. X}
  471. X
  472. X/*
  473. X** Define a string variables value, and set up the macro.
  474. X*/
  475. Xstatic void
  476. X_set_string_var(name, val, flag, var)
  477. Xchar *name;
  478. Xchar *val;
  479. Xint  flag;
  480. Xchar **var;
  481. X{
  482. X   HASHPTR hp;
  483. X
  484. X   hp = Def_macro(name, val, M_FLAG | flag);
  485. X   hp->ht_flag |= M_VAR_STRING | M_MULTI;
  486. X   hp->MV_SVAR  = var;
  487. X   *var         = hp->ht_value;
  488. X}
  489. X
  490. X/*
  491. X** Define a string variables value, and set up the macro.
  492. X*/
  493. Xstatic void
  494. X_set_bit_var(name, val, mask)
  495. Xchar *name;
  496. Xchar *val;
  497. Xint  mask;
  498. X{
  499. X   HASHPTR hp;
  500. X
  501. X   hp           = Def_macro(name, val, M_FLAG);
  502. X   hp->ht_flag |= M_VAR_BIT | M_MULTI;
  503. X   hp->MV_MASK  = mask;
  504. X   hp->MV_BVAR  = &Glob_attr;
  505. X}
  506. SHAR_EOF
  507. chmod 0440 imacs.c || echo "restore of imacs.c fails"
  508. echo "x - extracting hash.c (Text)"
  509. sed 's/^X//' << 'SHAR_EOF' > hash.c &&
  510. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/hash.c,v 1.1 90/10/06 12:03:45 dvadura Exp $
  511. X-- SYNOPSIS -- hashing function for hash tables.
  512. X-- 
  513. X-- DESCRIPTION
  514. X--      Hash an identifier.  The hashing function works by computing the sum
  515. X--      of each char and the previous hash value multiplied by 129.  Finally the
  516. X--      length of the identifier is added in.  This way the hash depends on the
  517. X--      chars as well as the length, and appears to be sufficiently unique,
  518. X--      and is FAST to COMPUTE, unlike the previous hash function...
  519. X-- 
  520. X-- AUTHOR
  521. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  522. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  523. X--
  524. X-- COPYRIGHT
  525. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  526. X-- 
  527. X--      This program is free software; you can redistribute it and/or
  528. X--      modify it under the terms of the GNU General Public License
  529. X--      (version 1), as published by the Free Software Foundation, and
  530. X--      found in the file 'LICENSE' included with this distribution.
  531. X-- 
  532. X--      This program is distributed in the hope that it will be useful,
  533. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  534. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  535. X--      GNU General Public License for more details.
  536. X-- 
  537. X--      You should have received a copy of the GNU General Public License
  538. X--      along with this program;  if not, write to the Free Software
  539. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  540. X--
  541. X-- LOG
  542. X--     $Log:    hash.c,v $
  543. X * Revision 1.1  90/10/06  12:03:45  dvadura
  544. X * dmake Release, Version 3.6
  545. X * 
  546. X*/
  547. X
  548. X#include "extern.h"
  549. X
  550. Xuint16
  551. XHash( id, phv )/*
  552. X=================
  553. X      This function computes the identifier's hash value and returns the hash
  554. X      value modulo the key size as well as the full hash value.  The reason
  555. X      for returning both is so that hash table searches can be sped up.  You
  556. X      compare hash keys instead and compare strings only for those whose 32-bit
  557. X      hash keys match. (not many) */
  558. X
  559. Xchar   *id;
  560. Xuint32 *phv;
  561. X{
  562. X   register char   *p    = id;
  563. X   register uint32 hash  = (uint32) 0;
  564. X
  565. X   while( *p ) hash = (hash << 7) + hash + (uint32) (*p++);
  566. X   *phv = hash = hash + (uint32) (p-id);
  567. X
  568. X   return( (uint16) (hash % HASH_TABLE_SIZE) );
  569. X}
  570. X
  571. SHAR_EOF
  572. chmod 0440 hash.c || echo "restore of hash.c fails"
  573. echo "x - extracting getinp.c (Text)"
  574. sed 's/^X//' << 'SHAR_EOF' > getinp.c &&
  575. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/getinp.c,v 1.1 90/10/06 12:03:43 dvadura Exp $
  576. X-- SYNOPSIS -- handle reading of input.
  577. X-- 
  578. X-- DESCRIPTION
  579. X--    The code in this file reads the input from the specified stream
  580. X--    into the provided buffer of size Buffer_size.  In doing so it deletes
  581. X--    comments.  Comments are delimited by the #, and
  582. X--    <nl> character sequences.  An exception is \# which
  583. X--    is replaced by # in the input.  Line continuations are signalled
  584. X--    at the end of a line and are recognized inside comments.
  585. X--    The line continuation is always  <\><nl>.
  586. X--
  587. X--    If the file to read is NIL(FILE) then the Get_line routine returns the
  588. X--    next rule from the builtin rule table if there is one.
  589. X--
  590. X-- AUTHOR
  591. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  592. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  593. X--
  594. X-- COPYRIGHT
  595. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  596. X-- 
  597. X--      This program is free software; you can redistribute it and/or
  598. X--      modify it under the terms of the GNU General Public License
  599. X--      (version 1), as published by the Free Software Foundation, and
  600. X--      found in the file 'LICENSE' included with this distribution.
  601. X-- 
  602. X--      This program is distributed in the hope that it will be useful,
  603. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  604. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  605. X--      GNU General Public License for more details.
  606. X-- 
  607. X--      You should have received a copy of the GNU General Public License
  608. X--      along with this program;  if not, write to the Free Software
  609. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  610. X--
  611. X-- LOG
  612. X--     $Log:    getinp.c,v $
  613. X * Revision 1.1  90/10/06  12:03:43  dvadura
  614. X * dmake Release, Version 3.6
  615. X * 
  616. X*/
  617. X
  618. X#include "extern.h"
  619. X#include "alloc.h"
  620. X#include "db.h"
  621. X
  622. X#define IS_WHITE(A)  ((A == ' ') || (A == '\t') || (A == '\n'))
  623. X#define SCAN_WHITE(A) \
  624. X    while( IS_WHITE(*A) ) A++;
  625. X
  626. Xstatic    int    _is_conditional ANSI((char*));
  627. Xstatic    int    _handle_conditional ANSI((int, TKSTRPTR));
  628. X
  629. Xstatic int  rule_ind = 0;    /* index of rule when reading Rule_tab     */
  630. Xstatic int  skip = FALSE;    /* if true the skip input         */
  631. X
  632. X
  633. Xint
  634. XGet_line( buf, fil )/*
  635. X======================
  636. X        Read a line of input from the file stripping
  637. X        off comments.  The routine returns TRUE if EOF */
  638. Xchar *buf;
  639. XFILE *fil;
  640. X{
  641. X   extern   char **Rule_tab;
  642. X   register char *p;
  643. X   register char *q;
  644. X   register char *c;
  645. X   char             *buf_org;
  646. X   static   int     ignore = FALSE;
  647. X   int          cont   = FALSE;
  648. X   int          pos    = 0;
  649. X   int         res;
  650. X
  651. X   DB_ENTER( "Get_line" );
  652. X
  653. X   if( fil == NIL(FILE) ) {
  654. X      /* Reading the internal rule table.  Set the rule_index to zero.
  655. X       * This way ReadEnvironment works as expected every time. */
  656. X
  657. X      while( (p = Rule_tab[ rule_ind++ ]) != NIL(char) )
  658. X     /* The last test in this if '*p != '~', handles the environment
  659. X      * passing conventions used by MKS to pass arguments.  We want to
  660. X      * skip those environment entries. */
  661. X     if( !Readenv || (Readenv && (strchr(p,'=') != NIL(char)) && *p!='~')){
  662. X        strcpy( buf, p );
  663. X
  664. X        DB_PRINT( "io", ("Returning [%s]", buf) );
  665. X        DB_RETURN( FALSE );
  666. X     }
  667. X
  668. X      rule_ind = 0;
  669. X
  670. X      DB_PRINT( "io", ("Done Ruletab") );
  671. X      DB_RETURN( TRUE );
  672. X   }
  673. X
  674. X   buf_org = buf;
  675. X
  676. Xdo_again:
  677. X   do {
  678. X      p = buf+pos;
  679. X      if(feof( fil ) || (fgets( p, Buffer_size-pos, fil ) == NIL(char)))
  680. X     DB_RETURN( TRUE );
  681. X
  682. X      Line_number++;
  683. X
  684. X      /* ignore input if ignore flag set and line ends in a continuation
  685. X     character. */
  686. X
  687. X      q = p+strlen(p)-2;
  688. X      if( ignore ) {
  689. X     if( q[0] != CONTINUATION_CHAR || q[1] != '\n' )  ignore = FALSE;
  690. X     *p = '\0';
  691. X     continue;
  692. X      }
  693. X
  694. X      /* Search the input string looking for comment chars.  If it contains
  695. X       * comment chars then NUKE the remainder of the line, if the comment
  696. X       * char is preceeded by \ then shift the remainder of the line left
  697. X       * by one char. */
  698. X
  699. X      c = p;
  700. X
  701. X      while( (c = strchr(c, COMMENT_CHAR)) != NIL(char) ) {
  702. X     if( c != p && c[-1] == ESCAPE_CHAR ) {
  703. X        strcpy( c-1, c );             /* copy it left, due to \# */
  704. X        q--;              /* shift tail pointer left */
  705. X     }
  706. X     else {
  707. X        *c = '\0';                    /* a true comment so break */
  708. X        break;
  709. X     }
  710. X      }
  711. X      
  712. X      /* Does the end of the line end in a continuation sequence? */
  713. X      
  714. X      if( (q[0] == CONTINUATION_CHAR) && (q[1] == '\n')) {
  715. X     /* If the continuation was at the end of a comment then ignore the
  716. X      * next input line, (or lines until we get one ending in just <nl>)
  717. X      * else it's a continuation, so build the input line from several
  718. X      * text lines on input.  The maximum size of this is governened by
  719. X      * Buffer_size */
  720. X     if( q != p && q[-1] == CONTINUATION_CHAR ) {
  721. X        strcpy( q, q+1 );
  722. X        q--;
  723. X        cont = FALSE;
  724. X     }
  725. X     else if( c != NIL(char) )
  726. X        ignore = TRUE;
  727. X     else
  728. X        cont   = TRUE;
  729. X      }
  730. X      else {
  731. X     cont = FALSE;
  732. X      }
  733. X
  734. X      q    = ( c == NIL(char) ) ? q+2 : c;
  735. X      pos += q-p;
  736. X   }
  737. X   while( (cont || !*buf) && (pos <= Buffer_size) );
  738. X
  739. X   if( buf[ pos-1 ] == '\n' )
  740. X      buf[ --pos ] = '\0';
  741. X   else
  742. X      if( pos == Buffer_size-1 )
  743. X     Fatal( "Input line too long, increase MAXLINELENGTH" );
  744. X
  745. X
  746. X   /* Now that we have the next line of input to make, we should check to
  747. X    * see if it is a conditional expression.  If it is then process it,
  748. X    * otherwise pass it on to the parser. */
  749. X
  750. X   if( *(p = _strspn(buf, " \t")) == CONDSTART ) {
  751. X      TKSTR token;
  752. X
  753. X      SET_TOKEN( &token, p );
  754. X
  755. X      p = Get_token( &token, "", FALSE );
  756. X
  757. X      if( (res = _is_conditional( p )) )    /* ignore non control special */
  758. X      {                        /* targets               */
  759. X     res  = _handle_conditional( res, &token );
  760. X     skip = TRUE;
  761. X      }
  762. X      else {
  763. X     CLEAR_TOKEN( &token );
  764. X     res  = TRUE;
  765. X      }
  766. X   }
  767. X
  768. X   if( skip ) {
  769. X      buf  = buf_org;        /* ignore line just read in */
  770. X      pos  = 0;
  771. X      skip = res;
  772. X      goto do_again;
  773. X   }
  774. X
  775. X   DB_PRINT( "io", ("Returning [%s]", buf) );
  776. X   DB_RETURN( FALSE );
  777. X}
  778. X
  779. X
  780. X
  781. Xchar *
  782. XGet_token( string, brk, anchor )/*
  783. X==================================
  784. X    Return the next token in string.
  785. X    Returns empty string when no more tokens in string.
  786. X    brk is a list of chars that also cause breaks in addition to space and
  787. X    tab, but are themselves returned as tokens.  if brk is NULL then the
  788. X    remainder of the line is returned as a single token.
  789. X    
  790. X    anchor if TRUE, says break on chars in the brk list, but only if
  791. X    the entire token begins with the first char of the brk list, if
  792. X    FALSE then any char of brk will cause a break to occurr. */
  793. X
  794. XTKSTRPTR  string;
  795. Xchar      *brk;
  796. Xint      anchor;
  797. X{
  798. X   register char *s;
  799. X   register char *curp;
  800. X   register char *t;
  801. X   int           done = FALSE;
  802. X   char          space[10];
  803. X
  804. X   DB_ENTER( "Get_token" );
  805. X
  806. X   s  = string->tk_str;              /* Get string parameters    */
  807. X   *s = string->tk_cchar;          /* ... and strip leading w/s    */
  808. X
  809. X   SCAN_WHITE( s );
  810. X
  811. X   DB_PRINT( "tok", ("What's left [%s]", s) );
  812. X
  813. X   if( !*s ) {
  814. X      DB_PRINT( "tok", ("Returning NULL token") );
  815. X      DB_RETURN( "" );
  816. X   }
  817. X
  818. X
  819. X   /* Build the space list.  space contains all those chars that may possibly
  820. X    * cause breaks.  This includes the brk list as well as white space. */
  821. X
  822. X   if( brk != NIL(char) ) {
  823. X      strcpy( space, " \t\n" );
  824. X      strcat( space, brk   );
  825. X   }
  826. X   else {
  827. X      space[0] = 0xff;            /* a char we know will not show up      */
  828. X      space[1] = 0;
  829. X   }
  830. X
  831. X
  832. X   /* Handle processing of quoted tokens.  Note that this is disabled if
  833. X    * brk is equal to NIL */
  834. X
  835. X   while( *s == '\"' && ((brk != NIL(char)) || !string->tk_quote) ) {
  836. X      s++;
  837. X      if( string->tk_quote ) {
  838. X     curp = s-1;
  839. X     do { curp = strchr( curp+1, '\"' ); }
  840. X     while( (curp != NIL(char)) && (*(curp+1) == '\"'));
  841. X
  842. X         if( curp == NIL(char) ) Fatal( "Unmatched quote in token" );
  843. X     string->tk_quote = !string->tk_quote;
  844. X
  845. X     /* Check for "" case, and if found ignore it */
  846. X     if( curp == s ) continue;
  847. X     goto found_token;
  848. X      }
  849. X      else
  850. X     SCAN_WHITE( s );
  851. X
  852. X      string->tk_quote = !string->tk_quote;
  853. X   }
  854. X   
  855. X
  856. X   /* Check for a token break character at the beginning of the token.
  857. X    * If found return the next set of break chars as a token. */
  858. X
  859. X   if( (brk != NIL(char)) && (strchr( brk, *s ) != NIL(char)) ) {
  860. X      curp = _strspn( s, brk );
  861. X      done = (anchor == 0) ? TRUE :
  862. X         ((anchor == 1)?(*s == *brk) : (*brk == curp[-1]));
  863. X   }
  864. X
  865. X
  866. X   /* Scan for the next token in the list and return it less the break char
  867. X    * that was used to terminate the token.  It will possibly be returned in
  868. X    * the next call to Get_token */
  869. X
  870. X   if( !done ) {
  871. X      SCAN_WHITE( s );
  872. X
  873. X      t = s;
  874. X      do {
  875. X     done = TRUE;
  876. X     curp = _strpbrk(t, space);
  877. X     
  878. X     if( anchor && *curp && !IS_WHITE( *curp ) )
  879. X        if( ((anchor == 1)?*curp:_strspn(curp,brk)[-1]) != *brk ) {
  880. X           t++;
  881. X           done = FALSE;
  882. X        }
  883. X      }
  884. X      while( !done );
  885. X
  886. X      if( (curp == s) && (strchr(brk, *curp) != NIL(char)) ) curp++;
  887. X   }
  888. X
  889. Xfound_token:
  890. X   string->tk_str   = curp;
  891. X   string->tk_cchar = *curp;
  892. X   *curp = '\0';
  893. X
  894. X   DB_PRINT( "tok", ("Returning [%s]", s) );
  895. X   DB_RETURN( s );
  896. X}
  897. X
  898. X
  899. X
  900. Xstatic int
  901. X_is_conditional( tg )/*
  902. X=======================
  903. X    Look at tg and return it's value if it is a conditional identifier
  904. X    otherwise return 0. */
  905. Xchar *tg;
  906. X{
  907. X   DB_ENTER( "_is_conditional" );
  908. X   
  909. X   tg++;
  910. X   switch( *tg ) {
  911. X      case 'I': if( !strcmp( tg, "IF" )) DB_RETURN( ST_IF   ); break;
  912. X      
  913. X      case 'E':
  914. X         if( !strcmp( tg, "END" ))     DB_RETURN( ST_END  );
  915. X         else if( !strcmp( tg, "ELSE" )) DB_RETURN( ST_ELSE );
  916. X     break;
  917. X   }
  918. X   
  919. X   DB_RETURN( 0 );
  920. X}
  921. X
  922. X
  923. X
  924. Xstatic int
  925. X_handle_conditional( opcode, tg )/*
  926. X===================================
  927. X    Perform the necessary processing for .IF conditinal targets.
  928. X    Someday this should be modified to do bracketted expressions ala
  929. X    CPP... sigh */
  930. Xint      opcode;
  931. XTKSTRPTR tg;
  932. X{
  933. X   static short    action[MAX_COND_DEPTH];
  934. X   char     *tok, *lhs, *rhs, *op, *expr;
  935. X   int      result;
  936. X
  937. X   DB_ENTER( "_handle_conditional" );
  938. X
  939. X   switch( opcode ) {
  940. X      case ST_IF:
  941. X     if( Nest_level+1 == MAX_COND_DEPTH )
  942. X        Fatal( ".IF .ELSE ... .END nesting too deep" );
  943. X
  944. X     If_expand = TRUE;
  945. X     expr = Expand( Get_token( tg, NIL(char), FALSE ));
  946. X     If_expand = FALSE;
  947. X     lhs = _strspn( expr, " \t" );
  948. X     if( !*lhs ) lhs = NIL(char);
  949. X
  950. X     if( (op = _strstr( lhs, "==" )) == NIL(char) )
  951. X        op = _strstr( lhs, "!=" );
  952. X
  953. X     if( op == NIL(char) )
  954. X        result = (lhs != NIL(char));
  955. X     else {
  956. X        op[1] = op[0];
  957. X        if( lhs != op ) {
  958. X           for( tok = op-1; (tok != lhs) && ((*tok == ' ')||(*tok == '\t'));
  959. X                tok-- );
  960. X           tok[1] = '\0';
  961. X        }
  962. X        else
  963. X           lhs = NIL(char);
  964. X
  965. X        op++;
  966. X        rhs = _strspn( op+1, " \t" );
  967. X        if( !*rhs ) rhs = NIL(char);
  968. X
  969. X        if( (rhs == NIL(char)) || (lhs == NIL(char)) )
  970. X           result = (rhs == lhs) ? TRUE : FALSE;
  971. X        else {
  972. X           tok = rhs + strlen( rhs );
  973. X           for( tok=tok-1; (tok != lhs) && ((*tok == ' ')||(*tok == '\t'));
  974. X            tok--);
  975. X           tok[1] = '\0';
  976. X
  977. X           result = (strcmp( lhs, rhs ) == 0) ? TRUE : FALSE;
  978. X        }
  979. X
  980. X        if( *op == '!' ) result = !result;
  981. X     }
  982. X
  983. X     if( expr != NIL(char) ) FREE( expr );
  984. X     Nest_level++;
  985. X
  986. X     if( result )
  987. X        action[ Nest_level ] = action[ Nest_level-1 ];
  988. X     else
  989. X        action[ Nest_level ] = 1;
  990. X     break;
  991. X
  992. X      case ST_ELSE:
  993. X     if( Nest_level <= 0 ) Fatal( ".ELSE without .IF" );
  994. X     if( action[ Nest_level-1 ] != 1 )
  995. X        action[ Nest_level ] ^=  0x1;    /* flip between 0 and 1    */
  996. X     break;
  997. X
  998. X      case ST_END:
  999. X     Nest_level--;
  1000. X     if( Nest_level < 0 ) Fatal( "Unmatched .END" );
  1001. X     break;
  1002. X   }
  1003. X
  1004. X   DB_RETURN( action[ Nest_level ] );
  1005. X}
  1006. X
  1007. SHAR_EOF
  1008. chmod 0440 getinp.c || echo "restore of getinp.c fails"
  1009. echo "x - extracting function.c (Text)"
  1010. sed 's/^X//' << 'SHAR_EOF' > function.c &&
  1011. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/function.c,v 1.1 90/10/06 12:04:36 dvadura Exp $
  1012. X-- SYNOPSIS -- GNU style functions for dmake.
  1013. X-- 
  1014. X-- DESCRIPTION
  1015. X--     All GNU stule functions understood by dmake are implemented in this
  1016. X--    file.  Currently the only such function is $(mktmp ...) which is
  1017. X--    not part of GNU-make is an extension provided by dmake.
  1018. X--
  1019. X-- AUTHOR
  1020. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1021. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1022. X--
  1023. X-- COPYRIGHT
  1024. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1025. X-- 
  1026. X--      This program is free software; you can redistribute it and/or
  1027. X--      modify it under the terms of the GNU General Public License
  1028. X--      (version 1), as published by the Free Software Foundation, and
  1029. X--      found in the file 'LICENSE' included with this distribution.
  1030. X-- 
  1031. X--      This program is distributed in the hope that it will be useful,
  1032. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1033. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1034. X--      GNU General Public License for more details.
  1035. X-- 
  1036. X--      You should have received a copy of the GNU General Public License
  1037. X--      along with this program;  if not, write to the Free Software
  1038. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1039. X--
  1040. X-- LOG
  1041. X--     $Log:    function.c,v $
  1042. X * Revision 1.1  90/10/06  12:04:36  dvadura
  1043. X * dmake Release, Version 3.6
  1044. X * 
  1045. X*/
  1046. X
  1047. X#include "extern.h"
  1048. X#include "alloc.h"
  1049. X
  1050. Xstatic char *_exec_mktmp ANSI((char *, char *));
  1051. X
  1052. X
  1053. Xchar *
  1054. XExec_function(buf)/*
  1055. X====================
  1056. X   Execute the function given by the value of args.
  1057. X
  1058. X   So far mktmp is the only valid function, anything else elicits and error
  1059. X   message.  It is my hope to support the GNU style functions in this portion
  1060. X   of the code at some time in the future. */
  1061. Xchar *buf;
  1062. X{
  1063. X   char *fname;
  1064. X   char *args = NIL(char);
  1065. X   char *mod  = NIL(char);
  1066. X   char *res  = NIL(char);
  1067. X
  1068. X   /* This must succeed since the presence of ' ', \t or \n is what
  1069. X    * determines if this functions is called in the first place. */
  1070. X   fname = _substr(buf, args=_strpbrk(buf," \t\n"));
  1071. X
  1072. X   if( (mod = strchr(fname,',')) != NIL(char) ){
  1073. X      *mod = '\0';
  1074. X      mod++;
  1075. X   }
  1076. X
  1077. X   switch( *fname ) {
  1078. X      case 'm':
  1079. X     if( strncmp(fname,"mktmp", 5) == 0 ) res = _exec_mktmp(mod, args);
  1080. X     break;
  1081. X   }
  1082. X
  1083. X   if( res == NIL(char) ) {
  1084. X      Warning( "Function '%s' not implemented at this time", fname );
  1085. X      res = _strdup("");
  1086. X   }
  1087. X
  1088. X   return(res);
  1089. X}
  1090. X
  1091. X
  1092. Xstatic char *
  1093. X_exec_mktmp( mod, data )
  1094. Xchar *mod;
  1095. Xchar *data;
  1096. X{
  1097. X   register char *p;
  1098. X   char *tmpname;
  1099. X   FILE *tmpfile;
  1100. X   char *name;
  1101. X
  1102. X   tmpfile = Start_temp( "", Recipe_cell, Recipe_how, &tmpname );
  1103. X   data    = Expand(_strspn(data, " \t\n"));
  1104. X   name    = Recipe_cell ? Recipe_cell->CE_NAME:"makefile text";
  1105. X
  1106. X   for(p=strchr(data,'\n'); p; p=strchr(p,'\n')) {
  1107. X      char *q = _strspn(++p," \t");
  1108. X      strcpy(p,q);
  1109. X   }
  1110. X
  1111. X   Append_line( data, FALSE, tmpfile, name, FALSE, TRUE );
  1112. X   Close_temp( Recipe_how, tmpfile );
  1113. X   FREE(data);
  1114. X
  1115. X   return( (mod != NIL(char) && *mod) ? Expand(mod) : _strdup(tmpname) );
  1116. X}
  1117. SHAR_EOF
  1118. chmod 0440 function.c || echo "restore of function.c fails"
  1119. echo "x - extracting extern.h (Text)"
  1120. sed 's/^X//' << 'SHAR_EOF' > extern.h &&
  1121. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/extern.h,v 1.1 90/10/06 12:04:24 dvadura Exp $
  1122. X-- SYNOPSIS -- external declarations for dmake functions.
  1123. X-- 
  1124. X-- DESCRIPTION
  1125. X--    ANSI is a macro that allows the proper handling of ANSI style
  1126. X--    function declarations.
  1127. X-- 
  1128. X-- AUTHOR
  1129. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1130. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1131. X--
  1132. X-- COPYRIGHT
  1133. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1134. X-- 
  1135. X--      This program is free software; you can redistribute it and/or
  1136. X--      modify it under the terms of the GNU General Public License
  1137. X--      (version 1), as published by the Free Software Foundation, and
  1138. X--      found in the file 'LICENSE' included with this distribution.
  1139. X-- 
  1140. X--      This program is distributed in the hope that it will be useful,
  1141. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1142. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1143. X--      GNU General Public License for more details.
  1144. X-- 
  1145. X--      You should have received a copy of the GNU General Public License
  1146. X--      along with this program;  if not, write to the Free Software
  1147. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1148. X--
  1149. X-- LOG
  1150. X--     $Log:    extern.h,v $
  1151. X * Revision 1.1  90/10/06  12:04:24  dvadura
  1152. X * dmake Release, Version 3.6
  1153. X * 
  1154. X*/
  1155. X
  1156. X#ifndef EXTERN_h
  1157. X#define EXTERN_h
  1158. X
  1159. X#include "vextern.h"
  1160. X#include <stdlib.h>
  1161. X#include <string.h>
  1162. X
  1163. Xextern    void    Add_dfa ANSI((char *));
  1164. Xextern    void    Add_fringe ANSI((CELLPTR));
  1165. Xextern    void    Add_recipe_to_list ANSI((char *, int, int));
  1166. Xextern    LINKPTR    Add_prerequisite ANSI((HOWPTR, CELLPTR, int));
  1167. Xextern    char*    Apply_edit ANSI((char *, char *, char *, int, int));
  1168. Xextern    void    Append_line ANSI((char*, int, FILE*, char*, int, int));
  1169. Xextern    char*    basename ANSI((char*));
  1170. Xextern    void    Bind_rules_to_targets ANSI((int));
  1171. Xextern    char*    Build_path ANSI((char *, char *));
  1172. Xextern    void     Catch_signals ANSI((void (*)()));
  1173. Xextern    void    Check_circle ANSI((LINKPTR));
  1174. Xextern    void    Check_circle_dfa ANSI(());
  1175. Xextern    void    Clear_prerequisites ANSI((HOWPTR));
  1176. Xextern    void    Clear_signals ANSI(());
  1177. Xextern  void    Clean_up_processes ANSI(());
  1178. Xextern    FILE*    Closefile ANSI(());
  1179. Xextern  void    Close_temp ANSI((HOWPTR, FILE *));
  1180. Xextern    void    Create_macro_vars ANSI(());
  1181. Xextern    DFAPTR    Construct_dfa ANSI((char *));
  1182. Xextern    CELLPTR    Def_cell ANSI((char *, CELLPTR));
  1183. Xextern    HASHPTR    Def_macro ANSI((char *, char *, int));
  1184. Xextern    STRINGPTR    Def_recipe ANSI((char *, STRINGPTR, int, int));
  1185. Xextern    int     Do_cmnd ANSI((char *, int, int, CELLPTR, HOWPTR, int,int,int));
  1186. Xextern    time_t    Do_stat ANSI((char *, char *, char **));
  1187. Xextern    time_t    Do_time ANSI(());
  1188. Xextern    int    Do_touch ANSI((char *, char *, char **));
  1189. Xextern    void    Dump ANSI(());
  1190. Xextern    void    Dump_recipe ANSI((STRINGPTR));
  1191. Xextern    void     Epilog ANSI((int));
  1192. Xextern  char*   Exec_function ANSI((char *));
  1193. Xextern    char*    Expand ANSI((char *));
  1194. Xextern  CELLPTR Explode_cell ANSI((CELLPTR, CELLPTR));
  1195. Xextern  HOWPTR  Explode_how ANSI((HOWPTR, CELLPTR, int));
  1196. Xextern  LINKPTR Explode_prq ANSI((LINKPTR, CELLPTR, int));
  1197. Xextern  char*   Filename ANSI(());
  1198. Xextern    char*    Get_current_dir ANSI(());
  1199. Xextern    int    Get_line ANSI((char *, FILE *));
  1200. Xextern    HASHPTR    Get_name ANSI((char *, HASHPTR *, int, CELLPTR));
  1201. Xextern    char*    Get_suffix ANSI((char *));
  1202. Xextern    char    Get_switch_char ANSI(());
  1203. Xextern    char*    Get_token ANSI((TKSTRPTR, char *, int));
  1204. Xextern    uint16    Hash ANSI((char *,uint32 *));
  1205. Xextern  void    Handle_result ANSI((int, int, int, CELLPTR));
  1206. Xextern    int    If_root_path ANSI((char *));
  1207. Xextern    CELLPTR    Infer_recipe ANSI((CELLPTR, HOWPTR, DFASETPTR, CELLPTR));
  1208. Xextern    int    Macro_op ANSI((char *));
  1209. Xextern    int    Make ANSI((CELLPTR, HOWPTR, CELLPTR));
  1210. Xextern    void    Make_rules ANSI(());
  1211. Xextern  void    Map_esc ANSI((char *));
  1212. Xextern    DFALINKPTR    Match_dfa ANSI((char *));
  1213. Xextern    char*    My_malloc ANSI((unsigned int, char *, int));
  1214. Xextern    char*    My_calloc ANSI((unsigned int, unsigned int, char *, int));
  1215. Xextern    void    My_free ANSI((char *, char *, int));
  1216. Xextern  void    No_ram ANSI(());
  1217. Xextern    FILE*    Open_temp ANSI((char **, char *));
  1218. Xextern    FILE*    Openfile ANSI((char *, int));
  1219. Xextern  char**  Pack_argv ANSI((int, int, char *));
  1220. Xextern    void    Parse ANSI((FILE *));
  1221. Xextern    int    Parse_macro ANSI((char *, int));
  1222. Xextern    int    Parse_rule_def ANSI((int *));
  1223. Xextern    void    Pop_dir ANSI((int));
  1224. Xextern    void    Prolog ANSI((int, char **));
  1225. Xextern    int    Push_dir ANSI((CELLPTR, int));
  1226. Xextern    void    Quit ANSI(());
  1227. Xextern    char*    Read_env_string ANSI((char *));
  1228. Xextern    void    ReadEnvironment ANSI(());
  1229. Xextern  void    Remove_prq ANSI((CELLPTR));
  1230. Xextern    int    Rule_op ANSI((char *));
  1231. Xextern    int    runargv ANSI((CELLPTR, HOWPTR, int, int, int, int, char *));
  1232. Xextern    time_t    seek_arch ANSI((char*, char*));
  1233. Xextern    int    Set_dir ANSI((char *));
  1234. Xextern    int    Set_group_attributes ANSI((char *));
  1235. Xextern    void    Stat_target ANSI((CELLPTR, int));
  1236. Xextern  FILE*   Start_temp ANSI((char *, CELLPTR, HOWPTR, char **));
  1237. Xextern    int    Test_circle ANSI((CELLPTR, int));
  1238. Xextern    int    touch_arch ANSI((char*, char*));
  1239. Xextern  void    Unlink_temp_files ANSI((HOWPTR));
  1240. Xextern  void    Update_time_stamp ANSI((CELLPTR, HOWPTR));
  1241. Xextern  void    Void_lib_cache ANSI((char *, char *));
  1242. Xextern  int    Wait_for_child ANSI((int, int));
  1243. Xextern    int    Write_env_string ANSI((char *, char *));
  1244. X
  1245. Xextern    char*    _stradd ANSI((char *,char *, int));
  1246. Xextern    char*    _strapp ANSI((char *,char *));
  1247. Xextern    char*    _strjoin ANSI((char *,char *,int, int));
  1248. Xextern    char*    _strdup ANSI((char *));
  1249. Xextern    char*    _strpbrk ANSI((char *,char *));
  1250. Xextern    char*    _strspn ANSI((char *,char *));
  1251. Xextern    char*    _strstr ANSI((char *,char *));
  1252. Xextern    char*    _substr ANSI((char *,char *));
  1253. X
  1254. X/* Include this last as it invalidates some functions that are defined
  1255. X * externally above and turns them into no-ops.  Have to do this after
  1256. X * the extern declarations however. */
  1257. X#include "config.h"
  1258. X
  1259. X#endif
  1260. X
  1261. SHAR_EOF
  1262. chmod 0440 extern.h || echo "restore of extern.h fails"
  1263. echo "x - extracting expand.c (Text)"
  1264. sed 's/^X//' << 'SHAR_EOF' > expand.c &&
  1265. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/expand.c,v 1.1 90/10/06 12:03:40 dvadura Exp $
  1266. X-- SYNOPSIS -- macro expansion code.
  1267. X-- 
  1268. X-- DESCRIPTION
  1269. X--
  1270. X--    This routine handles all the necessary junk that deals with macro
  1271. X--    expansion.  It understands the following syntax.  If a macro is
  1272. X--    not defined it expands to NULL, and {} are synonyms for ().
  1273. X--
  1274. X--        $$      - expands to $
  1275. X--        {{      - expands to {
  1276. X--            }}      - expands to }
  1277. X--        $A      - expands to whatever the macro A is defined as
  1278. X--        $(AA)   - expands to whatever the macro AA is defined as
  1279. SHAR_EOF
  1280. echo "End of part 20"
  1281. echo "File expand.c is continued in part 21"
  1282. echo "21" > s2_seq_.tmp
  1283. exit 0
  1284.  
  1285.