server bugfixes regarding ghost lines and reading and writing to different files
This commit is contained in:
+1
-1
@@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
# it's encouraged to rename the binary something a little more unique
|
# it's encouraged to rename the binary something a little more unique
|
||||||
# organize in bin folder
|
# organize in bin folder
|
||||||
# ~/bin/ekho
|
#~/bin/ekho-cli
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# if I do this
|
# if I do this
|
||||||
# ~/bin/ekho-server &
|
#~/bin/ekho-server &
|
||||||
# I have no way I of restarting the process when it ends
|
# I have no way I of restarting the process when it ends
|
||||||
# might need to look into using Signals to restart, may PID?
|
# might need to look into using Signals to restart, may PID?
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth: Alex Celani
|
// Auth: Alex Celani
|
||||||
// File: server.go
|
// File: server.go
|
||||||
// Revn: 10-05-2023 2.0
|
// Revn: 10-17-2023 3.0
|
||||||
// Func: host connection, reply to speak.go
|
// Func: host connection, reply to speak.go
|
||||||
//
|
//
|
||||||
// TODO: add more /codes/ to handle
|
// TODO: add more /codes/ to handle
|
||||||
// add flags
|
// add flags?
|
||||||
// write usage and errors to logfile
|
// write usage and errors to logfile
|
||||||
// send logfile to client on request
|
// send logfile to client on request
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -30,6 +30,11 @@
|
|||||||
// fixed bug in /r2/ where removing quote at final
|
// fixed bug in /r2/ where removing quote at final
|
||||||
// position would break
|
// position would break
|
||||||
// removed deadcode from /r2/, unused "quit" bool?
|
// removed deadcode from /r2/, unused "quit" bool?
|
||||||
|
//*10-17-2023: fixed bug where quotes are read from and saved to two
|
||||||
|
// different files
|
||||||
|
// removed implicit newline at end of qfile to stop ghost
|
||||||
|
// line bug in /la/
|
||||||
|
// removed dead debug print in fread()
|
||||||
//
|
//
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
@@ -91,17 +96,16 @@ func checkN( err error, conn net.Conn ) {
|
|||||||
// read file and create quote list
|
// read file and create quote list
|
||||||
func fread() string {
|
func fread() string {
|
||||||
// open file "quotes", read entire file as bytes into qfile
|
// open file "quotes", read entire file as bytes into qfile
|
||||||
qfile, err := ioutil.ReadFile( "quotes" )
|
qfile, err := ioutil.ReadFile( "list.q" )
|
||||||
check( err ) // make sure read works
|
check( err ) // make sure read works
|
||||||
|
// there is a trailing newline in the file, not removing it caused
|
||||||
|
// bugs where a blank item was introduced into qlist and calling
|
||||||
|
// /la/ would produce a blank line on the client side that didn't
|
||||||
|
// really exist
|
||||||
|
qfile = qfile[:len( qfile ) - 1]
|
||||||
// cast bytes to string, split string over newline into array
|
// cast bytes to string, split string over newline into array
|
||||||
qlist = strings.Split( string( qfile ), "\n" )
|
qlist = strings.Split( string( qfile ), "\n" )
|
||||||
// remove last item in list ( trailing newline leaves empty item )
|
// deal with the trailing
|
||||||
qlist = qlist[:len( qlist ) - 1]
|
|
||||||
if false { // XXX debug print ( next )
|
|
||||||
for _, q := range qlist { // iterate over all quotes in list
|
|
||||||
fmt.Println( q ) // print quote
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return string( qfile ) // return file as string
|
return string( qfile ) // return file as string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user