[asterisk-commits] seanbright: branch group/asterisk-cpp r168436 - /team/group/asterisk-cpp/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 10 23:18:03 CST 2009


Author: seanbright
Date: Sat Jan 10 23:18:02 2009
New Revision: 168436

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168436
Log:
strings.c and xmldoc.c

Modified:
    team/group/asterisk-cpp/main/strings.c
    team/group/asterisk-cpp/main/xmldoc.c

Modified: team/group/asterisk-cpp/main/strings.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/strings.c?view=diff&rev=168436&r1=168435&r2=168436
==============================================================================
--- team/group/asterisk-cpp/main/strings.c (original)
+++ team/group/asterisk-cpp/main/strings.c Sat Jan 10 23:18:02 2009
@@ -51,8 +51,8 @@
 int __ast_str_helper(struct ast_str **buf, size_t max_len,
 	int append, const char *fmt, va_list ap)
 {
-	int res, need;
-	int offset = (append && (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_USED : 0;
+	int res;
+	size_t need, offset = (append && (*buf)->__AST_STR_LEN) ? (*buf)->__AST_STR_USED : 0;
 	va_list aq;
 
 	do {
@@ -98,13 +98,13 @@
 	return res;
 }
 
-void ast_str_substitute_variables(struct ast_str **buf, size_t maxlen, struct ast_channel *chan, const char *template)
+void ast_str_substitute_variables(struct ast_str **buf, size_t maxlen, struct ast_channel *chan, const char *strtemplate)
 {
 	int first = 1;
 	do {
 		ast_str_make_space(buf, maxlen ? maxlen :
-			(first ? strlen(template) * 2 : (*buf)->__AST_STR_LEN * 2));
-		pbx_substitute_variables_helper_full(chan, NULL, template, (*buf)->__AST_STR_STR, (*buf)->__AST_STR_LEN - 1, &((*buf)->__AST_STR_USED));
+			(first ? strlen(strtemplate) * 2 : (*buf)->__AST_STR_LEN * 2));
+		pbx_substitute_variables_helper_full(chan, NULL, strtemplate, (*buf)->__AST_STR_STR, (*buf)->__AST_STR_LEN - 1, &((*buf)->__AST_STR_USED));
 		first = 0;
 	} while (maxlen == 0 && (*buf)->__AST_STR_LEN - 5 < (*buf)->__AST_STR_USED);
 }

Modified: team/group/asterisk-cpp/main/xmldoc.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/xmldoc.c?view=diff&rev=168436&r1=168435&r2=168436
==============================================================================
--- team/group/asterisk-cpp/main/xmldoc.c (original)
+++ team/group/asterisk-cpp/main/xmldoc.c Sat Jan 10 23:18:02 2009
@@ -107,14 +107,14 @@
  */
 static int xmldoc_postbrlen(const char *postbr)
 {
-	int postbrreallen = 0, i;
+	int postbrreallen = 0;
 	size_t postbrlen;
 
 	if (!postbr) {
 		return 0;
 	}
 	postbrlen = strlen(postbr);
-	for (i = 0; i < postbrlen; i++) {
+	for (size_t i = 0; i < postbrlen; i++) {
 		if (postbr[i] == '\t') {
 			postbrreallen += 8 - (postbrreallen % 8);
 		} else {
@@ -133,13 +133,13 @@
  */
 static void xmldoc_setpostbr(char *postbr, size_t len, const char *text)
 {
-	int c, postbrlen = 0;
+	int postbrlen = 0;
 
 	if (!text) {
 		return;
 	}
 
-	for (c = 0; c < len; c++) {
+	for (size_t c = 0; c < len; c++) {
 		if (text[c] == '\t' || text[c] == ' ') {
 			postbr[postbrlen++] = text[c];
 		} else {
@@ -309,7 +309,7 @@
 {
 	struct ast_str *colorized;
 	char *wrapped = NULL;
-	int i, c, len, colorsection;
+	int len, colorsection;
 	char *tmp;
 	size_t bwinputlen;
 	static const int base_fg = COLOR_CYAN;
@@ -331,10 +331,10 @@
 		}
 	}
 
-	for (i = 0; i < bwinputlen; i++) {
+	for (size_t i = 0; i < bwinputlen; i++) {
 		colorsection = 0;
 		/* Check if we are at the beginning of a tag to be colorized. */
-		for (c = 0; c < ARRAY_LEN(colorized_tags); c++) {
+		for (size_t c = 0; c < ARRAY_LEN(colorized_tags); c++) {
 			if (strncasecmp(bwinput + i, colorized_tags[c].inittag, strlen(colorized_tags[c].inittag))) {
 				continue;
 			}
@@ -417,7 +417,6 @@
  */
 static void xmldoc_string_cleanup(const char *text, struct ast_str **output, int lastspaces)
 {
-	int i;
 	size_t textlen;
 
 	if (!text) {
@@ -433,7 +432,7 @@
 		return;
 	}
 
-	for (i = 0; i < textlen; i++) {
+	for (size_t i = 0; i < textlen; i++) {
 		if (text[i] == '\n' || text[i] == '\r') {
 			/* remove spaces/tabs/\n after a \n. */
 			while (text[i + 1] == '\t' || text[i + 1] == '\r' || text[i + 1] == '\n') {
@@ -525,7 +524,7 @@
 	tmpfmtlen = strlen(tmpfmt);
 	totlen = *len + tmpfmtlen + 1;
 
-	*syntax = ast_realloc(*syntax, totlen);
+	*syntax = (char *) ast_realloc(*syntax, totlen);
 
 	if (!*syntax) {
 		ast_free(tmpfmt);
@@ -594,10 +593,9 @@
 static int xmldoc_has_specialtags(struct ast_xml_node *fixnode)
 {
 	struct ast_xml_node *node = fixnode;
-	int i;
 
 	for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) {
-		for (i = 0; i < ARRAY_LEN(special_tags); i++) {
+		for (size_t i = 0; i < ARRAY_LEN(special_tags); i++) {
 			if (!strcasecmp(ast_xml_node_get_name(node), special_tags[i].tagname)) {
 				return 1;
 			}
@@ -1006,8 +1004,7 @@
  */
 static enum syntaxtype xmldoc_get_syntax_type(const char *type)
 {
-	int i;
-	for (i=0; i < ARRAY_LEN(stxtype); i++) {
+	for (size_t i = 0; i < ARRAY_LEN(stxtype); i++) {
 		if (!strcasecmp(stxtype[i].type, type)) {
 			return stxtype[i].stxtype;
 		}
@@ -1111,13 +1108,13 @@
 static int xmldoc_parse_specialtags(struct ast_xml_node *fixnode, const char *tabs, const char *posttabs, struct ast_str **buffer)
 {
 	struct ast_xml_node *node = fixnode;
-	int ret = 0, i, count = 0;
+	int ret = 0, count = 0;
 
 	if (!node || !ast_xml_node_get_children(node)) {
 		return ret;
 	}
 
-	for (i = 0; i < ARRAY_LEN(special_tags); i++) {
+	for (size_t i = 0; i < ARRAY_LEN(special_tags); i++) {
 		if (strcasecmp(ast_xml_node_get_name(node), special_tags[i].tagname)) {
 			continue;
 		}
@@ -1319,7 +1316,7 @@
 	struct ast_str *outputstr;
 	char *output;
 	struct ast_xml_node *node;
-	const char *typename;
+	const char *type_name;
 	const char *content;
 	int first = 1;
 
@@ -1358,27 +1355,27 @@
 		}
 
 		/* parse the <ref> node. 'type' attribute is required. */
-		typename = ast_xml_get_attribute(node, "type");
-		if (!typename) {
+		type_name = ast_xml_get_attribute(node, "type");
+		if (!type_name) {
 			continue;
 		}
 		content = ast_xml_get_text(node);
 		if (!content) {
-			ast_xml_free_attr(typename);
-			continue;
-		}
-		if (!strcasecmp(typename, "application")) {
+			ast_xml_free_attr(type_name);
+			continue;
+		}
+		if (!strcasecmp(type_name, "application")) {
 			ast_str_append(&outputstr, 0, "%s%s()",	(first ? "" : ", "), content);
-		} else if (!strcasecmp(typename, "function")) {
+		} else if (!strcasecmp(type_name, "function")) {
 			ast_str_append(&outputstr, 0, "%s%s", (first ? "" : ", "), content);
-		} else if (!strcasecmp(typename, "astcli")) {
+		} else if (!strcasecmp(type_name, "astcli")) {
 			ast_str_append(&outputstr, 0, "%s<astcli>%s</astcli>", (first ? "" : ", "), content);
 		} else {
 			ast_str_append(&outputstr, 0, "%s%s", (first ? "" : ", "), content);
 		}
 		first = 0;
 		ast_xml_free_text(content);
-		ast_xml_free_attr(typename);
+		ast_xml_free_attr(type_name);
 	}
 
 	output = ast_strdup(ast_str_buffer(outputstr));
@@ -1762,11 +1759,11 @@
 	struct ast_config *cfg = NULL;
 	struct ast_variable *var = NULL;
 	struct ast_flags cnfflags = { 0 };
-	int globret, i, dup, duplicate;
+	int globret, duplicate;
 	glob_t globbuf;
 
 	/* setup default XML documentation language */
-	snprintf(documentation_language, sizeof(documentation_language), default_documentation_language);
+	ast_copy_string(documentation_language, default_documentation_language, sizeof(documentation_language));
 
 	if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags)) && cfg != CONFIG_STATUS_FILEINVALID) {
 		for (var = ast_variable_browse(cfg, "options"); var; var = var->next) {
@@ -1803,10 +1800,10 @@
 
 	AST_RWLIST_WRLOCK(&xmldoc_tree);
 	/* loop over expanded files */
-	for (i = 0; i < globbuf.gl_pathc; i++) {
+	for (size_t i = 0; i < globbuf.gl_pathc; i++) {
 		/* check for duplicates (if we already [try to] open the same file. */
 		duplicate = 0;
-		for (dup = 0; dup < i; dup++) {
+		for (size_t dup = 0; dup < i; dup++) {
 			if (!strcmp(globbuf.gl_pathv[i], globbuf.gl_pathv[dup])) {
 				duplicate = 1;
 				break;
@@ -1834,7 +1831,7 @@
 			ast_xml_close(tmpdoc);
 			continue;
 		}
-		doc_tree = ast_calloc(1, sizeof(*doc_tree));
+		doc_tree = (struct documentation_tree *) ast_calloc(1, sizeof(*doc_tree));
 		if (!doc_tree) {
 			ast_log(LOG_ERROR, "Unable to allocate documentation_tree structure!\n");
 			ast_xml_close(tmpdoc);




More information about the asterisk-commits mailing list