aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authormarkw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-07-25 20:30:00 +0000
committermarkw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-07-25 20:30:00 +0000
commitc597747761d48b7c15e3dc9fc038e38b79ca89e9 (patch)
tree4f4b9b5d9d11280d27c62aaea202af2eeea78baf /docs
parentec05d0f3dcbb98f7ce3517c6c9f46a38a5678d3a (diff)
downloadbusybox-w32-c597747761d48b7c15e3dc9fc038e38b79ca89e9.tar.gz
busybox-w32-c597747761d48b7c15e3dc9fc038e38b79ca89e9.tar.bz2
busybox-w32-c597747761d48b7c15e3dc9fc038e38b79ca89e9.zip
Added a note in the "Tips and Pointer" section on the correct way to test for
string equivalence with strcmp(). git-svn-id: svn://busybox.net/trunk/busybox@906 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'docs')
-rw-r--r--docs/style-guide.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/style-guide.txt b/docs/style-guide.txt
index 28fb1fbfc..d1257b755 100644
--- a/docs/style-guide.txt
+++ b/docs/style-guide.txt
@@ -175,6 +175,23 @@ The following are simple coding guidelines that should be followed:
175 (Side Note: we might want to use a single file instead of two, food for 175 (Side Note: we might want to use a single file instead of two, food for
176 thought). 176 thought).
177 177
178 - There's a right way and a wrong way to test for sting equivalence with
179 strcmp:
180
181 The wrong way:
182
183 if (!strcmp(string, "foo")) {
184 ...
185
186 The right way:
187
188 if (strcmp(string, "foo") == 0){
189 ...
190
191 The use of the "equals" (==) operator in the latter example makes it much
192 more obvious that you are testing for equivalence. The former example with
193 the "not" (!) operator makes it look like you are testing for an error.
194
178 - Do not use old-style function declarations that declare variable types 195 - Do not use old-style function declarations that declare variable types
179 between the parameter list and opening bracket. Example: 196 between the parameter list and opening bracket. Example:
180 197