summaryrefslogtreecommitdiff
path: root/src/css-url.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/css-url.c')
-rw-r--r--src/css-url.c67
1 files changed, 5 insertions, 62 deletions
diff --git a/src/css-url.c b/src/css-url.c
index f97690d..8ee4e8c 100644
--- a/src/css-url.c
+++ b/src/css-url.c
@@ -1,5 +1,5 @@
/* Collect URLs from CSS source.
- Copyright (C) 1998, 2000, 2001, 2002, 2003, 2009, 2010, 2011 Free
+ Copyright (C) 1998, 2000, 2001, 2002, 2003, 2009, 2010, 2011, 2014 Free
Software Foundation, Inc.
This file is part of GNU Wget.
@@ -41,11 +41,7 @@ as that of the covered work. */
#include <wget.h>
#include <stdio.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
+#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
@@ -56,6 +52,7 @@ as that of the covered work. */
#include "html-url.h"
#include "css-tokens.h"
#include "css-url.h"
+#include "xstrndup.h"
/* from lex.yy.c */
extern char *yytext;
@@ -64,41 +61,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern YY_BUFFER_STATE yy_scan_bytes (const char *bytes,int len );
extern int yylex (void);
-#if 1
-const char *token_names[] = {
- "CSSEOF",
- "S",
- "CDO",
- "CDC",
- "INCLUDES",
- "DASHMATCH",
- "LBRACE",
- "PLUS",
- "GREATER",
- "COMMA",
- "STRING",
- "INVALID",
- "IDENT",
- "HASH",
- "IMPORT_SYM",
- "PAGE_SYM",
- "MEDIA_SYM",
- "CHARSET_SYM",
- "IMPORTANT_SYM",
- "EMS",
- "EXS",
- "LENGTH",
- "ANGLE",
- "TIME",
- "FREQ",
- "DIMENSION",
- "PERCENTAGE",
- "NUMBER",
- "URI",
- "FUNCTION"
-};
-#endif
-
/*
Given a detected URI token, get only the URI specified within.
Also adjust the starting position and length of the string.
@@ -111,12 +73,6 @@ const char *token_names[] = {
static char *
get_uri_string (const char *at, int *pos, int *length)
{
- char *uri;
- /*char buf[1024];
- strncpy(buf,at + *pos, *length);
- buf[*length] = '\0';
- DEBUGP (("get_uri_string: \"%s\"\n", buf));*/
-
if (0 != strncasecmp (at + *pos, "url(", 4))
return NULL;
@@ -142,14 +98,7 @@ get_uri_string (const char *at, int *pos, int *length)
*length -= 2;
}
- uri = xmalloc (*length + 1);
- if (uri)
- {
- strncpy (uri, at + *pos, *length);
- uri[*length] = '\0';
- }
-
- return uri;
+ return xstrndup (at + *pos, *length);
}
void
@@ -161,12 +110,6 @@ get_urls_css (struct map_context *ctx, int offset, int buf_length)
int pos, length;
char *uri;
- /*
- strncpy(tmp,ctx->text + offset, buf_length);
- tmp[buf_length] = '\0';
- DEBUGP (("get_urls_css: \"%s\"\n", tmp));
- */
-
/* tell flex to scan from this buffer */
yy_scan_bytes (ctx->text + offset, buf_length);
@@ -200,7 +143,7 @@ get_urls_css (struct map_context *ctx, int offset, int buf_length)
pos++;
length -= 2;
uri = xmalloc (length + 1);
- strncpy (uri, yytext + 1, length);
+ memcpy (uri, yytext + 1, length);
uri[length] = '\0';
}