LCOV - code coverage report
Current view: top level - src - gperfappgen.cpp (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 13 13 100.0 %
Date: 2015-01-05 16:01:02 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 8 100.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * gperfappgen.cpp - generates the gperf input file
       3                 :            :  *
       4                 :            :  * Copyright (C) 2005 Stefan Jahn <stefan@lkcc.org>
       5                 :            :  *
       6                 :            :  * This is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2, or (at your option)
       9                 :            :  * any later version.
      10                 :            :  *
      11                 :            :  * This software is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this package; see the file COPYING.  If not, write to
      18                 :            :  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
      19                 :            :  * Boston, MA 02110-1301, USA.
      20                 :            :  *
      21                 :            :  * $Id$
      22                 :            :  *
      23                 :            :  */
      24                 :            : 
      25                 :            : #if HAVE_CONFIG_H
      26                 :            : # include <config.h>
      27                 :            : #endif
      28                 :            : 
      29                 :            : #include <stdio.h>
      30                 :            : #include <stdlib.h>
      31                 :            : #include <string.h>
      32                 :            : 
      33                 :            : #include "evaluate.h"
      34                 :            : #include "equation.h"
      35                 :            : 
      36                 :            : using namespace qucs::eqn;
      37                 :            : 
      38                 :            : #include "gperfappgen.h"
      39                 :            : 
      40                 :            : /* The program is used to generate the input file for a gperf run. */
      41                 :          1 : int main (void) {
      42                 :            : 
      43                 :            :   struct application_t * app;
      44                 :            :   char * key;
      45                 :          1 :   int len, n = 0;
      46                 :            : 
      47                 :            :   // Print declarations.
      48                 :            :   fprintf (stdout,
      49                 :            :            "%%language=C++\n"
      50                 :            :            "%%define class-name gperfapphash\n"
      51                 :            :            "%%define lookup-function-name get\n"
      52                 :            :            "%%define slot-name key\n"
      53                 :            :            "%%define word-array-name applist\n"
      54                 :            :            "%%struct-type\n"
      55                 :            :            "struct appindex { const char * key; int index; };\n"
      56                 :          1 :            "%%%%\n");
      57                 :            : 
      58                 :            :   // Print hash key list.
      59         [ +  + ]:        704 :   for (app = applications; app->application != NULL; app++, n++) {
      60                 :        703 :     key = (char *) calloc (1, strlen (app->application) + app->nargs * 3 + 5);
      61                 :        703 :     strcat (key, app->application);
      62         [ +  + ]:       1896 :     for (int i = 0; i < app->nargs; i++) {
      63                 :       1193 :       strcat (key, "_");
      64                 :       1193 :       strcat (key, checker::tag2key (app->args[i]));
      65                 :            :     }
      66                 :        703 :     len = strlen (key);
      67                 :            :     fprintf (stdout, "\"%s\", %s%s%s%d\n", key,
      68                 :            :              len < 12 ? "\t" : "", len < 20 ? "\t" : "",
      69 [ +  + ][ +  + ]:        703 :              len < 28 ? "" : "", n);
      70                 :        703 :     free (key);
      71                 :            :   }
      72                 :            : 
      73                 :          1 :   return 0;
      74                 :            : }

Generated by: LCOV version 1.11