chvol

Simple interface to set PulseAudio's volume, with graphical feedback! 🔊

Commit
4e59f1d3f884829c2674e4e30d33b30ea5079276
Parent
72726143596128665cc2a19555a40b6a8fb081bb
Author
Pablo <pablo-pie@riseup.net>
Date

Fixed a lexer bug

Diffstats

2 files changed, 17 insertions, 13 deletions

Status Name Changes Insertions Deletions
Modified chvol.conf 2 files changed 9 9
Modified src/configure.c 2 files changed 8 4
diff --git a/chvol.conf b/chvol.conf
@@ -1,15 +1,15 @@
 [window]
-width           = 350
-height          = 60
-progress_height = 5
-y               = 15
-padding         = 20
-border          = 2
-timeout_ms      = 1500
+width           = 350  # px
+height          = 60   # px
+progress_height = 5    # px
+y               = 15   # %
+padding         = 20   # px
+border          = 2    # px
+timeout_ms      = 1500 # ms
 
 [volume]
-increment    = 10
-cap          = 200
+increment    = 10  # %
+cap          = 200 # %
 audio_sample = "./assets/volume-change.ogg"
 
 [theme]
diff --git a/src/configure.c b/src/configure.c
@@ -156,7 +156,7 @@ b8 parse_sample(const char* path, PCM* pcm)
     ov_clear(&f);
     return false;
   }
-  
+
   i32 channels    = info->channels;
   i64 sample_rate = info->rate;
 
@@ -246,7 +246,7 @@ void sb_clear(SB *sb)
 // = minimal DOS-INI lexer/parser =============================================
 typedef struct {
   const char* src_path;
-  
+
   const char* data;
   u64         cursor;
   u64         count;
@@ -412,7 +412,8 @@ void lexer_skip_whitespace(Lexer* l)
 
       l->cursor++;
       l->current_line++;
-      l->current_line_start = l->cursor + 1;
+      l->current_line_start = l->cursor;
+      c = l->data[l->cursor];
     }
 
     if (!isspace(c)) break;
@@ -487,11 +488,14 @@ const char* escape_char(char c)
 
 b8 lexer_next(Lexer* l, Token* token)
 {
+  assert(l->cursor >= l->current_line_start);
+  assert(l->count  >= l->current_line_start);
+
   Location loc;
   loc.src_path         = l->src_path;
   loc.line             = l->current_line + 1;
   loc.offset           = l->cursor - l->current_line_start;
-  loc.text_start.data  = l->data + l->current_line_start;
+  loc.text_start.data  = l->data   + l->current_line_start;
   loc.text_start.count = l->count  - l->current_line_start;
 
   if (lexer_finished(l)) {