SF.net SVN: geany-plugins:[2104] trunk/geany-plugins/pretty-printer/src
ctabin at users.sourceforge.net
ctabin at xxxxx
Fri Jul 22 12:33:30 UTC 2011
Revision: 2104
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2104&view=rev
Author: ctabin
Date: 2011-07-22 12:33:30 +0000 (Fri, 22 Jul 2011)
Log Message:
-----------
XML Pretty-Printer: a lot of warning fixed
Modified Paths:
--------------
trunk/geany-plugins/pretty-printer/src/ConfigUI.c
trunk/geany-plugins/pretty-printer/src/PluginEntry.c
trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c
trunk/geany-plugins/pretty-printer/src/PrettyPrinter.h
Modified: trunk/geany-plugins/pretty-printer/src/ConfigUI.c
===================================================================
--- trunk/geany-plugins/pretty-printer/src/ConfigUI.c 2011-07-22 09:57:55 UTC (rev 2103)
+++ trunk/geany-plugins/pretty-printer/src/ConfigUI.c 2011-07-22 12:33:30 UTC (rev 2104)
@@ -167,11 +167,11 @@
GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
GtkWidget* lbl = gtk_label_new("Indentation");
- GtkWidget* comboChar = gtk_combo_box_text_new();
+ GtkWidget* comboChar = gtk_combo_box_new_text();
GtkWidget* spinIndent = gtk_spin_button_new_with_range(0, 100, 1);
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "Tab");
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "Space");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboChar), "Tab");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboChar), "Space");
gtk_combo_box_set_active(GTK_COMBO_BOX(comboChar), (indentation == ' ') ? 1 : 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinIndent), count);
@@ -196,11 +196,11 @@
GtkWidget* leftBox = gtk_vbox_new(FALSE, 6);
GtkWidget* lbl = gtk_label_new("Line break");
- GtkWidget* comboChar = gtk_combo_box_text_new();
+ GtkWidget* comboChar = gtk_combo_box_new_text();
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "\\r");
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "\\n");
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboChar), "\\r\\n");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboChar), "\\r");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboChar), "\\n");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(comboChar), "\\r\\n");
int active = 0;
if (strlen(lineReturn) == 2) active = 2;
Modified: trunk/geany-plugins/pretty-printer/src/PluginEntry.c
===================================================================
--- trunk/geany-plugins/pretty-printer/src/PluginEntry.c 2011-07-22 09:57:55 UTC (rev 2103)
+++ trunk/geany-plugins/pretty-printer/src/PluginEntry.c 2011-07-22 12:33:30 UTC (rev 2104)
@@ -25,10 +25,10 @@
//========================================== PLUGIN INFORMATION ==========================================================
-PLUGIN_VERSION_CHECK(130);
+PLUGIN_VERSION_CHECK(130)
PLUGIN_SET_INFO("XML PrettyPrinter", "Formats an XML and makes it human-readable.",
- "1.11", "Cédric Tabin - http://www.astorm.ch");
-PLUGIN_KEY_GROUP(prettyprinter, 1);
+ "1.2", "Cédric Tabin - http://www.astorm.ch")
+PLUGIN_KEY_GROUP(prettyprinter, 1)
//========================================== DECLARATIONS ================================================================
@@ -96,12 +96,12 @@
}
}
-static void kb_run_xml_pretty_print(G_GNUC_UNUSED guint key_id)
+void kb_run_xml_pretty_print(G_GNUC_UNUSED guint key_id)
{
xml_format(NULL, NULL);
}
-static void xml_format(GtkMenuItem* menuitem, gpointer gdata)
+void xml_format(GtkMenuItem* menuitem, gpointer gdata)
{
//retrieves the current document
GeanyDocument* doc = document_get_current();
Modified: trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c
===================================================================
--- trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c 2011-07-22 09:57:55 UTC (rev 2103)
+++ trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c 2011-07-22 12:33:30 UTC (rev 2104)
@@ -22,7 +22,7 @@
//xml pretty printing functions
static void putCharInBuffer(char charToAdd); //put a char into the new char buffer
-static void putCharsInBuffer(char* charsToAdd); //put the chars into the new char buffer
+static void putCharsInBuffer(const char* charsToAdd); //put the chars into the new char buffer
static void putNextCharsInBuffer(int nbChars); //put the next nbChars of the input buffer into the new buffer
static int readWhites(gboolean considerLineBreakAsWhite); //read the next whites into the input buffer
static char readNextChar(); //read the next char into the input buffer;
@@ -49,7 +49,7 @@
static void processDoctypeElement(); //process a DOCTYPE ELEMENT node
//debug function
-static void printError(char *msg, ...); //just print a message like the printf method
+static void printError(const char *msg, ...); //just print a message like the printf method
static void printDebugStatus(); //just print some variables into the console for debugging
//============================================ PRIVATE PROPERTIES ======================================
@@ -139,30 +139,30 @@
PrettyPrintingOptions* createDefaultPrettyPrintingOptions()
{
- PrettyPrintingOptions* options = (PrettyPrintingOptions*)malloc(sizeof(PrettyPrintingOptions));
- if (options == NULL)
+ PrettyPrintingOptions* defaultOptions = (PrettyPrintingOptions*)malloc(sizeof(PrettyPrintingOptions));
+ if (defaultOptions == NULL)
{
g_error("Unable to allocate memory for PrettyPrintingOptions");
return NULL;
}
- options->newLineChars = "\r\n";
- options->indentChar = ' ';
- options->indentLength = 2;
- options->oneLineText = FALSE;
- options->inlineText = TRUE;
- options->oneLineComment = FALSE;
- options->inlineComment = TRUE;
- options->oneLineCdata = FALSE;
- options->inlineCdata = TRUE;
- options->emptyNodeStripping = TRUE;
- options->emptyNodeStrippingSpace = TRUE;
- options->forceEmptyNodeSplit = FALSE;
- options->trimLeadingWhites = TRUE;
- options->trimTrailingWhites = TRUE;
- options->commentAlign = TRUE;
+ defaultOptions->newLineChars = "\r\n";
+ defaultOptions->indentChar = ' ';
+ defaultOptions->indentLength = 2;
+ defaultOptions->oneLineText = FALSE;
+ defaultOptions->inlineText = TRUE;
+ defaultOptions->oneLineComment = FALSE;
+ defaultOptions->inlineComment = TRUE;
+ defaultOptions->oneLineCdata = FALSE;
+ defaultOptions->inlineCdata = TRUE;
+ defaultOptions->emptyNodeStripping = TRUE;
+ defaultOptions->emptyNodeStrippingSpace = TRUE;
+ defaultOptions->forceEmptyNodeSplit = FALSE;
+ defaultOptions->trimLeadingWhites = TRUE;
+ defaultOptions->trimTrailingWhites = TRUE;
+ defaultOptions->commentAlign = TRUE;
- return options;
+ return defaultOptions;
}
void putNextCharsInBuffer(int nbChars)
@@ -191,13 +191,13 @@
++xmlPrettyPrintedIndex;
}
-void putCharsInBuffer(char* charsToAdd)
+void putCharsInBuffer(const char* charsToAdd)
{
- int index = 0;
- while (charsToAdd[index] != '\0')
+ int currentIndex = 0;
+ while (charsToAdd[currentIndex] != '\0')
{
- putCharInBuffer(charsToAdd[index]);
- ++index;
+ putCharInBuffer(charsToAdd[currentIndex]);
+ ++currentIndex;
}
}
@@ -278,7 +278,7 @@
int secondChar = inputBuffer[inputBufferIndex+1]; //should be '!'
int thirdChar = inputBuffer[inputBufferIndex+2]; //should be '-' or '['
- int index = inputBufferIndex+1;
+ int currentIndex = inputBufferIndex+1;
if (firstChar == '<')
{
//another node is being open ==> no inline !
@@ -292,33 +292,33 @@
//read until closing
char oldChar = ' ';
- index += 3; //that by pass meanless chars
+ currentIndex += 3; //that by pass meanless chars
gboolean loop = TRUE;
while (loop)
{
- char current = inputBuffer[index];
+ char current = inputBuffer[currentIndex];
if (current == closingComment && oldChar == closingComment) { loop = FALSE; } //end of comment
oldChar = current;
- ++index;
+ ++currentIndex;
}
//okay now avoid blanks
// inputBuffer[index] is now '>'
- ++index;
- while (isWhite(inputBuffer[index])) { ++index; }
+ ++currentIndex;
+ while (isWhite(inputBuffer[currentIndex])) { ++currentIndex; }
}
else
{
//this is a text node. Simply loop to the next '<'
- while (inputBuffer[index] != '<') { ++index; }
+ while (inputBuffer[currentIndex] != '<') { ++currentIndex; }
}
//check what do we have now
- char currentChar = inputBuffer[index];
+ char currentChar = inputBuffer[currentIndex];
if (currentChar == '<')
{
//check if that is a closing node
- currentChar = inputBuffer[index+1];
+ currentChar = inputBuffer[currentIndex+1];
if (currentChar == '/')
{
//as we are in a correct XML (so far...), if the node is
@@ -334,13 +334,13 @@
gboolean isOnSingleLine(int skip, char stop1, char stop2)
{
int currentIndex = inputBufferIndex+skip; //skip the n first chars (in comment <!--)
- gboolean isOnSingleLine = TRUE;
+ gboolean onSingleLine = TRUE;
char oldChar = inputBuffer[currentIndex];
char currentChar = inputBuffer[currentIndex+1];
- while(isOnSingleLine && oldChar != stop1 && currentChar != stop2)
+ while(onSingleLine && oldChar != stop1 && currentChar != stop2)
{
- isOnSingleLine = !isLineBreak(oldChar);
+ onSingleLine = !isLineBreak(oldChar);
++currentIndex;
oldChar = currentChar;
@@ -352,7 +352,7 @@
* are only spaces and it may be wanted to be considered as a single
* line). //TODO externalize an option for that ?
*/
- if (!isOnSingleLine)
+ if (!onSingleLine)
{
while(oldChar != stop1 && currentChar != stop2)
{
@@ -370,7 +370,7 @@
}
}
- return isOnSingleLine;
+ return onSingleLine;
}
void resetBackwardIndentation(gboolean resetLineBreak)
@@ -575,8 +575,8 @@
int i;
for (i=0 ; i<nodeNameLength ; ++i)
{
- int index = xmlPrettyPrintedIndex-nodeNameLength+i;
- nodeName[i] = xmlPrettyPrinted[index];
+ int tempIndex = xmlPrettyPrintedIndex-nodeNameLength+i;
+ nodeName[i] = xmlPrettyPrinted[tempIndex];
}
currentNodeName = nodeName; //set the name for using in other methods
@@ -711,14 +711,14 @@
if (!loop && options->commentAlign) //end of comment
{
//ensures the chars preceding the first '-' are all spaces
- gboolean rewind = xmlPrettyPrinted[xmlPrettyPrintedIndex-3] == ' ' &&
- xmlPrettyPrinted[xmlPrettyPrintedIndex-4] == ' ' &&
- xmlPrettyPrinted[xmlPrettyPrintedIndex-5] == ' ' &&
- xmlPrettyPrinted[xmlPrettyPrintedIndex-6] == ' ' &&
- xmlPrettyPrinted[xmlPrettyPrintedIndex-7] == ' ';
+ gboolean onlySpaces = xmlPrettyPrinted[xmlPrettyPrintedIndex-3] == ' ' &&
+ xmlPrettyPrinted[xmlPrettyPrintedIndex-4] == ' ' &&
+ xmlPrettyPrinted[xmlPrettyPrintedIndex-5] == ' ' &&
+ xmlPrettyPrinted[xmlPrettyPrintedIndex-6] == ' ' &&
+ xmlPrettyPrinted[xmlPrettyPrintedIndex-7] == ' ';
//if all the preceding chars are white, then go for replacement
- if (rewind)
+ if (onlySpaces)
{
xmlPrettyPrintedIndex -= 7; //remove indentation spaces
putCharsInBuffer("--"); //reset the first chars of '-->'
@@ -975,7 +975,7 @@
result = PRETTY_PRINTING_NOT_SUPPORTED_YET;
}
-void printError(char *msg, ...)
+void printError(const char *msg, ...)
{
va_list va;
va_start(va, msg);
Modified: trunk/geany-plugins/pretty-printer/src/PrettyPrinter.h
===================================================================
--- trunk/geany-plugins/pretty-printer/src/PrettyPrinter.h 2011-07-22 09:57:55 UTC (rev 2103)
+++ trunk/geany-plugins/pretty-printer/src/PrettyPrinter.h 2011-07-22 12:33:30 UTC (rev 2104)
@@ -43,7 +43,7 @@
*/
typedef struct
{
- char* newLineChars; //char used to generate a new line (generally \r\n)
+ const char* newLineChars; //char used to generate a new line (generally \r\n)
char indentChar; //char used for indentation
int indentLength; //number of char to use for indentation (by default 2 spaces)
gboolean oneLineText; //text is put on one line
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Plugins-Commits
mailing list