[PATCH] Fixing dive notes escape characters in World map exporter
Lubomir I. Ivanov
neolit123 at gmail.com
Thu Apr 3 08:47:04 PDT 2014
On 3 April 2014 16:34, Gehad Elrobey <gehadelrobey at gmail.com> wrote:
> I still want to fix this bug, can you please tell me what is wrong in the
> patch and how can i fix it ?
>
hello,
the patch has some formatting issues. please refer to the CodingStyle
in the project root folder.
(NOTE: can we automate this? i saw that Qt have a bot, which is quite
cool, but patches are submitted to a system of some sort - different
from a mailing list)
--------
+char* replace_char(char * str, char replace, char* replace_by)
+{
the * symbol should be next to the name, e.g.:
char *replace_char(char *str, char replace, char *replace_by)
+ /*
+ this fumction can't replace a character with a substring
+ where the substring contains the character, infinte loop.
+ */
+
+ if (!str) {
+ return 0;
+ }
no { } for single lines in "if..then" statements.
+
+ int i=0, char_count=0, new_size;
+
there should be spaces around "=".
+ while (str[i]!='\0') {
+ if (str[i]==replace) {
+ char_count++;
+ }
again spaces around "!=", "=="
no need for { } around char_count++;
you could use a pointer instead of str[i], but this should work as well.
+ i++;
+ }
+
+ new_size = strlen(str) + char_count * strlen(replace_by) + 1;
+ char* result = malloc(new_size);
+ char* temp = malloc(new_size);
char *result
char *temp
+ char *p0, *p1;
+ if (!result || !temp) {
+ return 0;
+ }
no need for the { }.
+ strcpy(temp, str);
+ result[0] = '\0';
+ p0=temp;
spaces around "=".
+ p1 = strchr(temp, replace);
+ while (p1) {
+ *p1 = '\0';
+ strcat(result, p0);
+ strcat(result, replace_by);
+ p0 = p1 +1;
space after "p1 +"
+ p1 = strchr(p0, replace);
+ }
+ strcat(result, p0);/*concat the rest of the string*/
space should be added before the /* comment
+ free(temp);
+ return result;
+}
+
+char* quote(char * string)
+{
char * quote(char *string)
+ char* new_line_removed = replace_char(string,'\n',"<br>");
+ char* single_quotes_removed = replace_char(new_line_removed,'\'',"'");
char *...
spaces are needed after argument list elements separated with ",".
arg1, arg2, arg3
+ free(new_line_removed);
+ return single_quotes_removed;
+}
+
void put_HTML_notes(struct membuffer *b,struct dive *dive)
{
if (dive->notes) {
- put_format(b,"<p>Notes : %s </p>",dive->notes);
+ char* notes = quote(dive->notes);
+ put_format(b,"<p>Notes : %s </p>",notes);
+ free(notes);
}
}
needs spaces after argument list elements separated with ",".
lubomir
--
More information about the subsurface
mailing list