LCOV - code coverage report
Current view: top level - libreoffice/dmake - imacs.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 74 75 98.7 %
Date: 2012-12-17 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* RCS  $Id: imacs.c,v 1.9 2008-03-05 18:29:01 kz Exp $
       2             : --
       3             : -- SYNOPSIS
       4             : --      Define default internal macros.
       5             : --
       6             : -- DESCRIPTION
       7             : --  This file adds to the internal macro tables the set of default
       8             : --  internal macros, and for those that are accessible internally via
       9             : --  variables creates these variables, and initializes them to point
      10             : --  at the default values of these macros.
      11             : --
      12             : -- AUTHOR
      13             : --      Dennis Vadura, dvadura@dmake.wticorp.com
      14             : --
      15             : -- WWW
      16             : --      http://dmake.wticorp.com/
      17             : --
      18             : -- COPYRIGHT
      19             : --      Copyright (c) 1996,1997 by WTI Corp.  All rights reserved.
      20             : --
      21             : --      This program is NOT free software; you can redistribute it and/or
      22             : --      modify it under the terms of the Software License Agreement Provided
      23             : --      in the file <distribution-root>/readme/license.txt.
      24             : --
      25             : -- LOG
      26             : --      Use cvs log to obtain detailed change logs.
      27             : */
      28             : 
      29             : #include "extern.h"
      30             : 
      31             : static  void    _set_int_var ANSI((char *, char *, int, int *));
      32             : static  void    _set_string_var ANSI((char *, char *, int, char **));
      33             : static  void    _set_bit_var ANSI((char *, char *, int));
      34             : 
      35             : 
      36             : PUBLIC void
      37         184 : Make_rules()/*
      38             : ==============
      39             :    Parse the strings stored in Rule_tab (from ruletab.c). */
      40             : {
      41         184 :    Parse(NIL(FILE));
      42         184 : }
      43             : 
      44             : 
      45             : #define M_FLAG   M_DEFAULT | M_EXPANDED
      46             : 
      47             : /*
      48             : ** Add to the macro table all of the internal macro variables plus
      49             : ** create secondary variables which will give access to their values
      50             : ** easily, both when needed and when the macro value is modified.
      51             : ** The latter is accomplished by providing a flag in the macro and a field
      52             : ** which gives a pointer to the value if it is a char or string macro value
      53             : ** and a mask representing the bit of the global flag register that is affected
      54             : ** by this macro's value.
      55             : */
      56             : PUBLIC void
      57         188 : Create_macro_vars()
      58             : {
      59             :    static char* switchar;
      60             :    static char* version;
      61             :    char   swchar[2];
      62             :    char   buf[20];
      63             : 
      64         188 :    swchar[0] = Get_switch_char(), swchar[1] = '\0';
      65         188 :    _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
      66         188 :    if (*swchar == '/')
      67           0 :       DirSepStr = "\\";
      68             :    else
      69             : #if (_MPW)
      70             :          DirSepStr = ":";
      71             : #elif defined( __EMX__)
      72             :    /* Use '\' for OS/2 port. */
      73             :          DirSepStr = "\\";
      74             : #else
      75         188 :          DirSepStr = "/";
      76             : #endif
      77         188 :    _set_string_var("DIRSEPSTR", DirSepStr, M_DEFAULT,&DirSepStr);
      78         188 :    _set_string_var("DIRBRKSTR", DirBrkStr, M_DEFAULT, &DirBrkStr);
      79         188 :    swchar[0] = DEF_ESCAPE_CHAR, swchar[1] = '\0';
      80         188 :    _set_string_var(".ESCAPE_PREFIX", swchar, M_FLAG, &Escape_char);
      81             : 
      82             :    /* Each one the following attributes corresponds to a bit of
      83             :     * Glob_attr. */
      84         188 :    _set_bit_var(".SILENT",   "", A_SILENT  );
      85         188 :    _set_bit_var(".IGNORE",   "", A_IGNORE  );
      86         188 :    _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
      87         188 :    _set_bit_var(".EPILOG",   "", A_EPILOG  );
      88         188 :    _set_bit_var(".PROLOG",   "", A_PROLOG  );
      89         188 :    _set_bit_var(".NOINFER",  "", A_NOINFER );
      90         188 :    _set_bit_var(".SEQUENTIAL","",A_SEQ     );
      91         188 :    _set_bit_var(".USESHELL", "", A_SHELL   );
      92             :    /* .SWAP (MSDOS) and .WINPATH (cygwin) share the same bit. */
      93         188 :    _set_bit_var(".SWAP",     "", A_SWAP    );
      94         188 :    _set_bit_var(".WINPATH",  "", A_WINPATH );
      95         188 :    _set_bit_var(".MKSARGS",  "", A_MKSARGS );
      96         188 :    _set_bit_var(".IGNOREGROUP","",A_IGNOREGROUP);
      97             : 
      98         188 :    Glob_attr = A_DEFAULT;        /* set all flags to NULL   */
      99             : 
     100         188 :    _set_string_var("SHELL",        "",  M_DEFAULT, &Shell       );
     101         188 :    _set_string_var("SHELLFLAGS",   " ", M_DEFAULT, &Shell_flags );
     102         188 :    _set_string_var("SHELLCMDQUOTE","",  M_DEFAULT, &Shell_quote );
     103         188 :    _set_string_var("GROUPSHELL",   "",  M_DEFAULT, &GShell      );
     104         188 :    _set_string_var("GROUPFLAGS",   " ", M_DEFAULT, &GShell_flags);
     105         188 :    _set_string_var("SHELLMETAS",   "",  M_DEFAULT, &Shell_metas );
     106         188 :    _set_string_var("GROUPSUFFIX",  "",  M_DEFAULT, &Grp_suff    );
     107         188 :    _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake     );
     108         188 :    _set_string_var("OOODMAKEMODE", "",  M_DEFAULT, &OOoDmMode );
     109         188 :    _set_string_var(".KEEP_STATE",  "",  M_DEFAULT, &Keep_state  );
     110         188 :    _set_string_var(".NOTABS",      "",  M_MULTI, &Notabs );
     111         188 :    _set_string_var(".DIRCACHE",    "y", M_DEFAULT, &UseDirCache );
     112             : 
     113             : #if CASE_INSENSITIVE_FS
     114             : #define DIRCACHERESPCASEDEFAULT ""
     115             : #else
     116             : #define DIRCACHERESPCASEDEFAULT "y"
     117             : #endif
     118         188 :    _set_string_var(".DIRCACHERESPCASE", DIRCACHERESPCASEDEFAULT, M_DEFAULT, &DcacheRespCase);
     119             : 
     120         188 :    _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,
     121             :            &Makedir_macval);
     122         188 :    Makedir = DmStrDup(Makedir_macval); /* Later done by Def_macro(). */
     123         188 :    _set_string_var("MAKEVERSION", VERSION, M_PRECIOUS, &version);
     124         188 :    _set_string_var("PWD",  Makedir,  M_PRECIOUS|M_NOEXPORT, &Pwd_macval);
     125         188 :    Pwd = DmStrDup(Pwd_macval); /* Later done by Def_macro(). */
     126         188 :    _set_string_var("TMD",  ".",      M_PRECIOUS|M_NOEXPORT, &Tmd_macval);
     127         188 :    Tmd = DmStrDup(Tmd_macval); /* Later done by _set_tmd(). */
     128             : 
     129         188 :    Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
     130             : 
     131             :    /* Initialize a macro that contains a space. As leading and trailing
     132             :     * spaces are stripped by Def_macro a little cheating is necessary. */
     133         188 :    _set_string_var("SPACECHAR", "x", M_PRECIOUS|M_NOEXPORT|M_FLAG, &Spacechar );
     134         188 :    Spacechar[0] = ' ';
     135             : 
     136         188 :    _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
     137         188 :    _set_int_var( "PREP",          "0", M_DEFAULT, &Prep );
     138         188 :    (void) Def_macro("MAXLINELENGTH", "1024", M_FLAG | M_DEFAULT);
     139             : 
     140             :    /* MAXPROCESSLIMIT is overwritten by the ruletab.c settings. Set its
     141             :     * initial value high so that it allows MAXPROCESS to be changed
     142             :     * from the command line. */
     143         188 :    _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT,&Max_proclmt );
     144             : #if defined(USE_CREATEPROCESS)
     145             :    /* Set the OS early enough. */
     146             :    Max_proclmt = MAXIMUM_WAIT_OBJECTS;
     147             : #endif
     148         188 :    _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
     149         188 :    sprintf(buf,"%d",NAME_MAX);
     150         188 :    _set_int_var( "NAMEMAX", buf, M_DEFAULT|M_NOEXPORT, &NameMax);
     151         188 : }
     152             : 
     153             : 
     154             : /*
     155             : ** Define an integer variable value, and set up the macro.
     156             : */
     157             : static void
     158         940 : _set_int_var(name, val, flag, var)
     159             : char *name;
     160             : char *val;
     161             : int  flag;
     162             : int  *var;
     163             : {
     164             :    HASHPTR hp;
     165             : 
     166         940 :    hp = Def_macro(name, val, M_FLAG | flag);
     167         940 :    hp->ht_flag |= M_VAR_INT | M_MULTI | M_INIT;
     168         940 :    hp->MV_IVAR  = var;
     169         940 :    *var         = atoi(val);
     170         940 : }
     171             : 
     172             : 
     173             : /*
     174             : ** Define a string variables value, and set up the macro.
     175             : */
     176             : static void
     177        4136 : _set_string_var(name, val, flag, var)
     178             : char *name;
     179             : char *val;
     180             : int  flag;
     181             : char **var;
     182             : {
     183             :    HASHPTR hp;
     184             : 
     185        4136 :    hp = Def_macro(name, val, M_FLAG | flag);
     186        4136 :    hp->ht_flag |= M_VAR_STRING | M_MULTI | M_INIT;
     187        4136 :    hp->MV_SVAR  = var;
     188        4136 :    *var         = hp->ht_value;
     189        4136 : }
     190             : 
     191             : 
     192             : /* Define a bit variable value, and set up the macro. Each of the bits
     193             :  * corresponds to an attribute bit of Glob_attr. */
     194             : static void
     195        2256 : _set_bit_var(name, val, mask)
     196             : char *name;
     197             : char *val;
     198             : int  mask;
     199             : {
     200             :    HASHPTR hp;
     201             : 
     202        2256 :    hp           = Def_macro(name, val, M_FLAG);
     203        2256 :    hp->ht_flag |= M_VAR_BIT | M_MULTI | M_INIT;
     204        2256 :    hp->MV_MASK  = mask;
     205        2256 :    hp->MV_BVAR  = &Glob_attr;
     206        2256 : }

Generated by: LCOV version 1.10