LCOV - code coverage report
Current view: top level - soltools/cpp - _unix.c (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 84 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <stdio.h>
      21             : #include <stddef.h>
      22             : #include <stdlib.h>
      23             : #include <string.h>
      24             : #include <ctype.h>
      25             : #include <fcntl.h>
      26             : #if (defined(_WIN32) || defined(__IBMC__))
      27             : #include <io.h>
      28             : #else
      29             : #include <unistd.h>
      30             : #endif
      31             : 
      32             : #include "cpp.h"
      33             : 
      34             : #if defined MACOSX || defined AIX || defined WNT
      35             : #include <_getopt.h>
      36             : #else
      37             : #include <getopt.h>
      38             : #endif
      39             : 
      40             : int Pflag = 0;                          /* print no line information */
      41             : int Iflag = 0;                          /* print includes */
      42             : int Mflag = 0;                          /* print macor expansion */
      43             : int Aflag = 0;                          /* translate character sets */
      44             : int Xflag = 0;                          /* print pragma for include/import */
      45             : int Vflag = 0;                          /* verbose flag */
      46             : int Cflag = 0;                          /* do not remove any comments */
      47             : int Dflag = 0;                          /* add parameter check to delete op */
      48             : int Cplusplus = 0;
      49             : 
      50             : void
      51           0 :     setup(int argc, char **argv)
      52             : {
      53             :     int c, fd, i, n;
      54             :     char *fp, *dp;
      55             :     Tokenrow tr;
      56             : 
      57           0 :     setup_kwtab();
      58             : #if defined MACOSX || defined(AIX) || defined WNT
      59             :     while ((c = stgetopt(argc, argv, "NOPV:I:D:U:F:A:X:u:l:+")) != -1)
      60             : #else
      61           0 :     while ((c = getopt(argc, argv, "NOPV:I:D:U:F:A:X:u:l:+")) != -1)
      62             : #endif
      63           0 :         switch (c)
      64             :         {
      65             :             case 'N':
      66           0 :                 for (i = 0; i < NINCLUDE; i++)
      67           0 :                     if (includelist[i].always == 1)
      68           0 :                         includelist[i].deleted = 1;
      69           0 :                 break;
      70             : 
      71             :             case 'I':
      72           0 :                 for (i = NINCLUDE - 2; i >= 0; i--)
      73             :                 {
      74           0 :                     if (includelist[i].file == NULL)
      75             :                     {
      76           0 :                         includelist[i].always = 1;
      77           0 :                         includelist[i].file = optarg;
      78           0 :                         break;
      79             :                     }
      80             :                 }
      81           0 :                 if (i < 0)
      82           0 :                     error(FATAL, "Too many -I directives");
      83           0 :                 break;
      84             : 
      85             :             case 'D':
      86             :             case 'U':
      87             :             case 'A':
      88           0 :                 setsource("<cmdarg>", -1, -1, optarg, 0);
      89           0 :                 maketokenrow(3, &tr);
      90           0 :                 gettokens(&tr, 1);
      91           0 :                 doadefine(&tr, c);
      92           0 :                 unsetsource();
      93           0 :                 break;
      94             : 
      95             :             case 'P':                   /* Lineinfo */
      96           0 :                 Pflag++;
      97           0 :                 break;
      98             : 
      99             :             case 'V':
     100           0 :                 for (n = 0; (c = optarg[n]) != '\0'; n++)
     101           0 :                     switch (c)
     102             :                     {
     103             :                         case 'i':
     104           0 :                             Iflag++;
     105           0 :                             break;
     106             : 
     107             :                         case 'm':
     108           0 :                             Mflag = 1;
     109           0 :                             break;
     110             : 
     111             :                         case 'x':
     112           0 :                             Mflag = 2;
     113           0 :                             break;
     114             : 
     115             :                         case 't':
     116           0 :                             Vflag++;
     117           0 :                             break;
     118             : 
     119             :                         case 'v':
     120           0 :                             fprintf(stderr, "%s\n", argv[0]);
     121           0 :                             break;
     122             : 
     123             :                         default:
     124           0 :                             error(WARNING, "Unknown verbose option %c", c);
     125             :                     }
     126           0 :                 break;
     127             : 
     128             :             case 'X':
     129           0 :                 for (n = 0; (c = optarg[n]) != '\0'; n++)
     130           0 :                     switch (c)
     131             :                     {
     132             :                         case 'a':
     133           0 :                             Aflag++;
     134           0 :                             break;
     135             : 
     136             :                         case 'i':
     137           0 :                             Xflag++;
     138           0 :                             break;
     139             : 
     140             :                         case 'c':
     141           0 :                             Cflag++;
     142           0 :                             break;
     143             : 
     144             :                         case 'd':
     145           0 :                             Dflag++;
     146           0 :                             break;
     147             : 
     148             :                         case 'w':
     149           0 :                             dp = &optarg[n + 1];
     150           0 :                             n += (int)strlen(dp);
     151           0 :                             while (isspace(*dp)) dp++;
     152             : 
     153           0 :                             for (i = NINCLUDE - 1; i >= 0; i--)
     154             :                             {
     155           0 :                                 if (wraplist[i].file == NULL)
     156             :                                 {
     157           0 :                                     wraplist[i].file = dp;
     158           0 :                                     break;
     159             :                                 }
     160             :                             }
     161           0 :                             if (i < 0)
     162           0 :                                 error(WARNING, "Too many -Xw directives");
     163           0 :                             break;
     164             : 
     165             :                         default:
     166           0 :                             error(WARNING, "Unknown extension option %c", c);
     167             :                     }
     168           0 :                 break;
     169             : 
     170             :             case '+':
     171           0 :                 Cplusplus++;
     172           0 :                 break;
     173             : 
     174             :             case 'u':                   /* -undef fuer GCC (dummy) */
     175             :             case 'l':                   /* -lang-c++ fuer GCC (dummy) */
     176           0 :                 break;
     177             : 
     178             :             default:
     179           0 :                 break;
     180             :         }
     181           0 :     dp = ".";
     182           0 :     fp = "<stdin>";
     183           0 :     fd = 0;
     184           0 :     if (optind < argc)
     185             :     {
     186           0 :         if ((fp = strrchr(argv[optind], '/')) != NULL)
     187             :         {
     188           0 :             int len = (int)(fp - argv[optind]);
     189             : 
     190           0 :             dp = (char *) newstring((uchar *) argv[optind], len + 1, 0);
     191           0 :             dp[len] = '\0';
     192             :         }
     193           0 :         fp = (char *) newstring((uchar *) argv[optind], strlen(argv[optind]), 0);
     194           0 :         if ((fd = open(fp, O_RDONLY)) <= 0)
     195           0 :             error(FATAL, "Can't open input file %s", fp);
     196             :     }
     197             : 
     198           0 :     if (optind + 1 < argc)
     199             :     {
     200           0 :         int fdo = creat(argv[optind + 1], 0666);
     201             : 
     202           0 :         if (fdo < 0)
     203           0 :             error(FATAL, "Can't open output file %s", argv[optind + 1]);
     204             : 
     205           0 :         dup2(fdo, 1);
     206             :     }
     207           0 :     includelist[NINCLUDE - 1].always = 0;
     208           0 :     includelist[NINCLUDE - 1].file = dp;
     209           0 :     setsource(fp, -1, fd, NULL, 0);
     210           0 : }
     211             : 
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10