Comments (5)
Thanks Simon.
I can make the small change. Yeah I forgot to assign after the replace.
from ols.
It already does.
It works fine for Linux, so someone with a MacOS has to figure out why this doesn't work:
home := os.get_env("HOME", context.temp_allocator)
strings.replace(forward_path, "~", home, 1, context.temp_allocator)
from ols.
Hi @DanielGavin
Thought I would try to help with this bug report as I use Odin and macOS.
I tested the above suggested code on macOS and found the code suggested does not work as expected. It does not work on Linux (Ubuntu 22.04.2 LTS
on Raspberry Pi) either.
The example output from the test code below on both macOS and Linux is:
% odin run dir_test.odin -file
example path: '~/.Odin'
checking 'forward_path[0]': '126' [~]
env HOME is: '/Users/simon'
Orignal OLS code - updated 'forward_path' is: '~/.Odin'
New code - updated 'forward_path' is: '/Users/simon/.Odin'
Example code used to test:
// run with: odin run dir_test.odin -file
package main
import "core:fmt"
import "core:strings"
import "core:os"
main :: proc() {
// create an example path to test in macOS
forward_path : string = "~/.Odin"
fmt.printf("\nexample path: '%s'\n",forward_path)
// Lines below extract from: ols/src/server/requests.odin lines 515-530
// with additional 'fmt.printf' statements added.
//
//Support a basic use of '~'
when ODIN_OS != .Windows {
fmt.printf("checking 'forward_path[0]': '%v' [%c]\n",forward_path[0],i32(forward_path[0]))
if forward_path[0] == '~' {
home := os.get_env(
"HOME",
context.temp_allocator,
)
fmt.printf("env HOME is: '%s'\n",home)
strings.replace(
forward_path,
"~",
home,
1,
context.temp_allocator,
)
fmt.printf("Orignal OLS code - updated 'forward_path' is: '%s'\n",forward_path)
//
// new code below - capture the 'replace' proc returned value
forward_path, _ := strings.replace(
forward_path,
"~",
home,
1,
context.temp_allocator,
)
fmt.printf("New code - updated 'forward_path' is: '%s'\n",forward_path)
}
}
}
Odin version used:
Odin: dev-2023-06:d97dd99d
OS: macOS Unknown (build: 22F66, kernel: 22.5.0)
CPU: ARM64
RAM: 8192 MiB
Odin: dev-2023-06:4c17e2e9
OS: Ubuntu 22.04.2 LTS, Linux 5.15.0-1029-raspi
CPU: ARM64
RAM: 7807 MiB
I could not see how to find the OLS version being used - but the last update made was:
commit 6b8e30e7ce91d24389a7ed20a6958f5272b10bfb (HEAD -> master, origin/master, origin/HEAD)
error: cannot run gpg: No such file or directory
Author: DanielGavin <[email protected]>
Date: Mon Jun 12 13:33:06 2023 +0200
Update README.md
Do you want me to create a PR with the above change to fix the use of strings.replace
or would you rather look at it yourself?
Hope that helps :)
Simon
from ols.
The code has been pushed.
from ols.
That's great @DanielGavin - glad it was useful.
from ols.
Related Issues (20)
- Newline in struct initialization not handled properly, And trailing space in struct initialization causes crash HOT 3
- OLS showing errors that don't appear on build and sometimes crashes HOT 1
- Comments at end of switch case get indented to case level HOT 1
- Wrong semantic tokens in proc type params without names
- Assignments not aligned when using bit_set HOT 4
- Assignment not aligned when using selector call
- This code causes ols to crash HOT 1
- Missing pointer information in generic types
- New line inside aggregate initialization, what is desired behavior? HOT 2
- ols fails to build with latest master branch of Odin. HOT 1
- Autocomplete and errors fail on sub-packages HOT 3
- No type inference for element when using for in loop
- Odinfmt: first comment after `// odinfmt: enable` get removed
- textDocument/documentSymbol is not supported HOT 2
- Question / feature request - when formatting, can newlines/carriage returns be made optional? Running into encoding issues. HOT 2
- Issue with use of `.?` in maybe variables
- On save server exits in Helix editor HOT 3
- Add "name": "base", "path":"C:\\odin\\base" to auto-generated ols.json to empower completions for base lib packages in ols HOT 1
- Cyclic struct declaration crashes langauge server client
- ols crashing, idk why HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ols.