diff --git a/options.cc b/options.cc
index a4f97f7bce67ccf613776996d5f372ca10c64bef..59d2fde0c00afa2aaec4727f9f260268f4b724b7 100644
--- a/options.cc
+++ b/options.cc
@@ -23,9 +23,9 @@ bool BaseOption::matches(const string& arg)
 {
   string::size_type pos = 0, np;
   while((np = key_.find(",", pos)) != string::npos) {
-    if(arg == key_.substr(pos, np))
+    if(arg == key_.substr(pos, np - pos))
       return true;
-    pos = np+1;
+    pos = np + 1;
   }
   if(arg == key_.substr(pos, string::npos))
     return true;