/* * regex.c * * Copyright (c) 2004 Chernookiy Vitaly <cvv@email.zp.ua> & Sergey Shkonda <serg@bcs.zp.ua> & Andrew W. Nosenko <awn@bcs.zp.ua> */ #include <stdlib.h> #include <stdio.h> #include <string.h> /* #if defined(HAVE_GNUREGEX_H) # include <gnuregex.h> #elif defined(HAVE_REGEX_H) # include <regex.h> #endif */ #include <regex.h> #ifndef MIN #define MIN(x,y) ((x < y) ? x : y) #endif #define PARSED_STRING "123,4567,898709" /*ûÁÂÌÏÎ ÒÏÚÐÁÒÓÉ ×ÁÎÉÑ ÐÁËÅÔÁ Ó ×ÅÓÏÍ*/ #define R_REGEX "^([^,]*),([^,]*),([^,]*)$" #define R_FIELD1 1 #define R_FIELD2 2 #define R_FIELD3 3 //========================================================================== void* safe_calloc(size_t nmemb, size_t size) { char* p; if (!nmemb || !size) return NULL; p = calloc(nmemb, size); /* __MEM_CHECKED__ */ if (!p) { fprintf(stderr,"not enough memory, exiting\n"); exit(EXIT_FAILURE); } return p; } //========================================================================== #define safe_free(p) { if (p) { free(p); p = NULL; } } //========================================================================== static struct re_pattern_buffer* make_regex_buf(char *expr) { struct re_pattern_buffer *r; const char *err; r = (struct re_pattern_buffer*) safe_calloc(1, sizeof(*r)); if (!r) return NULL; re_syntax_options = RE_BACKSLASH_ESCAPE_IN_LISTS | RE_CHAR_CLASSES | RE_NO_BK_BRACES | RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_INTERVALS; err = re_compile_pattern(expr, strlen(expr), r); if (err) { fprintf(stderr, "re_compile('%s'): %s", expr, err); safe_free(r); return NULL; } return r; }


Ответ на:
комментарий
от bugmaker


Ответ на:
комментарий
от cvv

Ответ на:
комментарий
от cvv

Ответ на:
комментарий
от signal11

Ответ на:
комментарий
от mky

Ответ на:
комментарий
от cvv

Ответ на:
комментарий
от signal11

Ответ на:
комментарий
от cvv

Ответ на:
комментарий
от signal11

Ответ на:
комментарий
от signal11

Ответ на:
комментарий
от signal11

Ответ на:
комментарий
от cvv

Ответ на:
комментарий
от signal11

Ответ на:
комментарий
от signal11

Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Похожие темы
- Форум troubles with /etc/hosts (2004)
- Форум mandrake linux...гоню? (2005)
- Форум MRTG и траблы (2007)
- Форум libcurl кракозябры (2017)
- Форум dlsym и malloc (2011)
- Форум падает книжный пример (2013)
- Форум socket error (2009)
- Форум Segmentation fault (2009)
- Форум С++ Проверка доступа в интернет с помощью библиотеки curl (2013)
- Форум Ошибка сегментирования. Рекурсивный обход каталогов (2017)