Add support for text macros with arguments.
[iverilog.git] / libveriuser / mc_scan_plusargs.c
blobd92eb1844ded41cf9f0020024b70d0c72b0980f4
1 /*
2 * Copyright (c) 2002 Michael Ruff (mruff at chiaro.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: mc_scan_plusargs.c,v 1.3 2002/08/12 01:35:02 steve Exp $"
21 #endif
23 # include <string.h>
24 # include <vpi_user.h>
25 # include <veriuser.h>
28 * mc_scan_plusargs implemented using VPI interface
30 char *mc_scan_plusargs(char *plusarg)
32 int argc, diff;
33 char **argv, *a, *p;
34 s_vpi_vlog_info vpi_vlog_info;
36 /* get command line */
37 if (! vpi_get_vlog_info(&vpi_vlog_info))
38 return (char *)0;
40 /* for each argument */
41 argv = vpi_vlog_info.argv;
42 for (argc = 0; argc < vpi_vlog_info.argc; argc++, argv++) {
43 a = *argv;
44 p = plusarg;
46 /* only plusargs */
47 if (*a != '+') continue;
48 a += 1;
50 /* impossible matches */
51 if (strlen(a) < strlen(p)) continue;
53 diff = 0;
54 while (*p) {
56 if (*a != *p) {
57 diff = 1;
58 break;
60 a++; p++;
63 if (!diff) return a;
66 /* didn't find it yet */
67 return (char *)0;
71 * $Log: mc_scan_plusargs.c,v $
72 * Revision 1.3 2002/08/12 01:35:02 steve
73 * conditional ident string using autoconfig.
75 * Revision 1.2 2002/05/24 21:46:21 steve
76 * Only match plusargs.
78 * Revision 1.1 2002/05/24 20:29:07 steve
79 * Implement mc_scan_plusargs.