[Vala] would like to eliminate compilation warning related to stripping whitespace from elements of a string []
- From: Reid Thompson <Reid Thompson ateb com>
- To: "vala-list gnome org" <vala-list gnome org>
- Subject: [Vala] would like to eliminate compilation warning related to stripping whitespace from elements of a string []
- Date: Fri, 21 Jun 2013 20:47:58 +0000
how do I implement the following to make the compilation warnings go
away?
$ cat readMDF.vala
/*valac --pkg gio-2.0 gio-sample.vala*/
int main (string[] args) {
// A reference to our file
var file = File.new_for_path (args[1]);
if (!file.query_exists ()) {
stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
return 1;
}
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
// stdout.printf ("%s\n", line);
// foreach(var field in line.split("|")){
// stdout.printf ("%s\n", field);
// }
var fieldAry = line.split("|");
int i = 0;
while(i<fieldAry.length){
stdout.printf ("%6d%60s\n", i, fieldAry[i].strip());
i++;
}
// foreach(string fl in fieldAry) {
// string as = fl.to_string();
// stdout.printf ("%60s\n", as.strip());
// }
}
} catch (Error e) {
error ("%s", e.message);
}
return 0;
}
[16:41:16][0s] rthompso raker2 ateb com> ~
$ valac --pkg gee-1.0 --pkg gio-2.0 readMDF.vala
/home/rthompso/readMDF.vala.c: In function ‘string_strip’:
/home/rthompso/readMDF.vala.c:34:2: warning: passing argument 1 of ‘g_strchug’ discards ‘const’ qualifier
from pointer target type [enabled by default]
/usr/include/glib-2.0/glib/gstrfuncs.h:177:23: note: expected ‘gchar *’ but argument is of type ‘const gchar
*’
/home/rthompso/readMDF.vala.c: In function ‘main’:
/home/rthompso/readMDF.vala.c:186:2: warning: ‘g_type_init’ is deprecated (declared at
/usr/include/glib-2.0/gobject/gtype.h:669) [-Wdeprecated-declarations]
[16:41:22][0s] rthompso raker2 ateb com> ~
$ ./readMDF ./testPipeFile.txt
0 No trimming needed
1 leading whitespace
2 trailing whitespace
3 both leading and trailing whitespace
4
[16:41:26][0s] rthompso raker2 ateb com> ~
$ cat ./testPipeFile.txt
No trimming needed| leading whitespace|trailing whitespace | both leading and trailing whitespace |
--
If you have received the message in error, please advise the sender by
reply email and please delete the message. This message contains
information which may be confidential or otherwise protected. Unless
you are the addressee (or authorized to receive for the addressee), you
may not use, copy, or disclose to anyone the message or any information
contained in the message.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]