HVML / PurC

The prime HVML interpreter for C Language.
GNU Lesser General Public License v3.0
1.05k stars 54 forks source link

Fedora fixes #55

Closed bkmgit closed 1 year ago

bkmgit commented 1 year ago

Addressing https://github.com/HVML/PurC/issues/40

VincentWei commented 1 year ago

Many thanks for your pull requests! It looks very good. We will review it asap.

yongkangl commented 1 year ago

Oops, confirmed the first one but looks all patches are approved, is it possible to cancel the action?

LTreeshu commented 1 year ago

good job!

VincentWei commented 1 year ago

I revised pcdvobjs_get_current_timezone() for the correct coding style:

bool
pcdvobjs_get_current_timezone(char *buff, size_t sz_buff)
{
    const char *timezone;
    char path[PATH_MAX + 1];

    const char* env_tz = getenv("TZ");
    if (env_tz) {
        if (env_tz[0] == ':')
            timezone = env_tz + 1;
        if (!pcdvobjs_is_valid_timezone(timezone)) {
            timezone = "posixrules";
        }
    }
    else {
        ssize_t nr_bytes;
        nr_bytes = readlink(PURC_SYS_TZ_FILE, path, sizeof(path) - 1);
        if (nr_bytes > 0)
             path[nr_bytes] = '\0';
        if ((nr_bytes > 0) &&
            (strstr(path, PURC_SYS_TZ_DIR) != NULL)) {
                    timezone = strstr(path, PURC_SYS_TZ_DIR) +
                                    sizeof(PURC_SYS_TZ_DIR) - 1;
        }
        else {
            purc_set_error(PURC_ERROR_BAD_SYSTEM_CALL);
            purc_log_error("Cannot determine timezone.\n");
            goto failed;
        }
    }

    if (strlen(timezone) >= sz_buff) {
        purc_set_error(PURC_ERROR_TOO_SMALL_BUFF);
        goto failed;
    }

    strcpy(buff, timezone);
    return true;

failed:
    return false;
}
VincentWei commented 1 year ago

I have merged the commits. However, I will revise the code for the correct coding style.

Thank @bkmgit and @yongkangl again for your efforts!

bkmgit commented 1 year ago

谢谢 . Would it be worth using tools such as indent or astyle?

VincentWei commented 1 year ago

谢谢 . Would it be worth using tools such as indent or astyle?

The coding style of PurC is basically like the one of Linux kernel:

https://www.kernel.org/doc/html/v4.10/process/coding-style.html

I think the programmer should write code in right coding style instead of relying on a cleaning tool. We only use the tools when we want to copy or import some old code into a new project.

bkmgit commented 1 year ago

老师谢谢。 本周将更新。

VincentWei commented 1 year ago

老师谢谢。 本周将更新。

I have merged your changes and revised the code for the correct coding style.

I will push the commits to this repository in a few days.