[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
more about gdbinit
From: |
remove CAPS |
Subject: |
more about gdbinit |
Date: |
Sun, 8 Jul 2001 21:38:01 -0400 |
hi again everyone,
i've been thinking more about the code i was looking at this past
weekend. there's a bit of logic that goes something like the following:
"if there's a '.gdbinit' in the current directory read and process it,
unless it's the same as the one in the user's $HOME directory"
i've talked about this in a past email. basically the if() condition
isn't strong enough, if you change the third parameter to
'catch_command_errors()' from "0" to "!batch" you'll see some error
output.
as it currently stands, even if the file in the current directory
doesn't exist that is considered sufficiently different from the one in
the $HOME directory to allow this code to execute (which, of course, if
the file doesn't exist, it shouldn't!)
i think a good C function to call here is "access". if you pass the
constant "F_OK" as the mode, the "access" function will basically check
to see if you can access this file, "F_OK" just checks to make sure the
file exists. we could also OR "F_OK" with "R_OK" to make sure that we
can also read this file.
the logic that is used to check to see if the two files are different
involves the use of the "stat" function. the entire structure the
"stat" function fills in is checked (using "memcmp"), but this
structure also gives information about inodes and other such stuff.
what i'm pointing out is that the one file would have to be a link to
the other in order for them to compare equal. so if you have two
distinct files, each of which has the exact same contents, the
comparison will show that they are different. i believe the original
intent was that the init file in the current directory should only be
processed if its contents aren't the same as the contents of the init
file in the $HOME directory.
so is there a C function that will compare the contents of two files? i
don't think so (but i could be wrong of course). i'd gladly write up
such a little function and provide it if anyone cares. i've added the
call to "access" in my own version, but without the check for file
differences it doesn't amount to much.
best regards,
trevor
ps. again, sorry for mangling my email, just remove the caps if you
want to reply personally.
--
http://home.ica.net/~vjbtlw/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- more about gdbinit,
remove CAPS <=