Deleted Added
sdiff udiff text old ( 228072 ) new ( 250125 )
full compact
1/** regex - regular expression functions related to POSIX regex lib. */
2
3/* This file is part of flex. */
4
5/* Redistribution and use in source and binary forms, with or without */
6/* modification, are permitted provided that the following conditions */
7/* are met: */
8

--- 41 unchanged lines hidden (view full) ---

50void flex_regcomp(regex_t *preg, const char *regex, int cflags)
51{
52 int err;
53
54 memset (preg, 0, sizeof (regex_t));
55
56 if ((err = regcomp (preg, regex, cflags)) != 0) {
57 const int errbuf_sz = 200;
58 char * errbuf=0;
59
60 errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
61 regerror (err, preg, errbuf, errbuf_sz);
62 snprintf (errbuf, errbuf_sz, "regcomp failed: %s\n", errbuf);
63
64 flexfatal (errbuf);
65 free(errbuf);
66 }
67}
68
69/** Extract a copy of the match, or NULL if no match.
70 * @param m A match as returned by regexec().
71 * @param src The source string that was passed to regexec().
72 * @return The allocated string.
73 */
74char *regmatch_dup (regmatch_t * m, const char *src)
75{
76 char *str;
77 int len;
78
79 if (m == NULL || m->rm_so < 0)
80 return NULL;
81 len = m->rm_eo - m->rm_so;
82 str = (char *) flex_alloc ((len + 1) * sizeof (char));
83 strncpy (str, src + m->rm_so, len);
84 str[len] = 0;
85 return str;
86}
87
88/** Copy the match.
89 * @param m A match as returned by regexec().
90 * @param dest The destination buffer.

--- 74 unchanged lines hidden ---