From owner-svn-src-head@freebsd.org Fri Feb 16 13:57:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 073B9F15F55 for ; Fri, 16 Feb 2018 13:57:48 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 65BAA7ABB1 for ; Fri, 16 Feb 2018 13:57:47 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-lf0-f49.google.com with SMTP id v9so2153143lfa.11 for ; Fri, 16 Feb 2018 05:57:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=DpPMD+zBTMsR+GwmYL6zKJRDfoK4MAPCuhZofwJ0ZXk=; b=SwE0z7RCOAhotYQxL0AyV3hWxplHz2FmPaqFexrp+WOpN+4so0lSJRm71LzRjMNhwe or7xH7RyBg94FMbyp/USL7CHhZpZUxlgX2CiTvqr7jDuOaBaorMfp+MOycxCozcz/LMT gj3uWbcbBMyMMb7HCxSlu+V2Fjqwusxh+EH8MuHBAAox8gLVvqfikDNInXzk4bP+p9rF nuFd3SnJeas4DCMRCk2EwHi1auqzilFJG0NizPednCO62hpipUl1bYLke6u17L8N1+s0 RwW2c5P2nZFWWmM83nm3pfcqjQFwWBGI+xWkhfuZe+kO2Gb3g63xqiKwmg7tfAwkIIKT lb1w== X-Gm-Message-State: APf1xPCB07NPlBJ4+Mk0u3ubCg6vHlcgAZKJu2sfxeIxEJgZWAJp0K/t ImlobBJQmPpPE8ijNSL1tg4f25ydMRE= X-Google-Smtp-Source: AH8x227RUoGUod2UZ0PQKVYOR5gQYbbfkD+7hMu0zFKpGJMzUX2qiFJNX/Ux+8f1jbi6PKntAt16bw== X-Received: by 10.46.99.11 with SMTP id x11mr4518702ljb.136.1518789459612; Fri, 16 Feb 2018 05:57:39 -0800 (PST) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com. [209.85.215.45]) by smtp.gmail.com with ESMTPSA id h76sm3534095ljh.77.2018.02.16.05.57.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 05:57:39 -0800 (PST) Received: by mail-lf0-f45.google.com with SMTP id x196so4125516lfd.12 for ; Fri, 16 Feb 2018 05:57:39 -0800 (PST) X-Received: by 10.46.64.203 with SMTP id r72mt5013130lje.38.1518789458740; Fri, 16 Feb 2018 05:57:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.106.8 with HTTP; Fri, 16 Feb 2018 05:57:18 -0800 (PST) In-Reply-To: <201802160312.w1G3CO3r085739@repo.freebsd.org> References: <201802160312.w1G3CO3r085739@repo.freebsd.org> From: Kyle Evans Date: Fri, 16 Feb 2018 07:57:18 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r329349 - head/stand/lua Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Feb 2018 13:57:48 -0000 On Thu, Feb 15, 2018 at 9:12 PM, Kyle Evans wrote: > Author: kevans > Date: Fri Feb 16 03:12:24 2018 > New Revision: 329349 > URL: https://svnweb.freebsd.org/changeset/base/329349 > > Log: > stand/lua: Reduce magic numbers > > Enter/backspace values are hardcoded in both the menu and password scripts. > Separate these out to core for reuse between the two. > > Modified: > head/stand/lua/core.lua > head/stand/lua/menu.lua > head/stand/lua/password.lua > > Modified: head/stand/lua/core.lua > ============================================================================== > --- head/stand/lua/core.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/core.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -28,6 +28,10 @@ > > local core = {}; > > +-- Commonly appearing constants > +core.KEY_ENTER = 13 > +core.KEY_BACKSPACE = 127 > + > function core.setVerbose(b) > if (b == nil) then > b = not core.verbose; > > Modified: head/stand/lua/menu.lua > ============================================================================== > --- head/stand/lua/menu.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/menu.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -273,9 +273,9 @@ function menu.run(m) > local key = io.getchar(); > > -- Special key behaviors > - if (key == 127) and (m ~= menu.welcome) then > + if (key == core.KEY_BACKSPACE) and (m ~= menu.welcome) then > break > - elseif (key == 13) then > + elseif (key == core.KEY_ENTER) then > core.boot(); > -- Should not return > end > @@ -357,7 +357,7 @@ function menu.autoboot() > screen.defcursor(); > if io.ischar() then > local ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > else > -- prevent autoboot when escaping to interpreter > > Modified: head/stand/lua/password.lua > ============================================================================== > --- head/stand/lua/password.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/password.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -37,11 +37,11 @@ function password.read() > > repeat > ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > end > > - if ch == 8 then > + if ch == core.KEY_BACKSPACE then It's worth noting that this changes the comparison from 'ch == 8' to 'ch == 127'. The password prompt was non-functional on my test systems until this change, because I can never type my password right the first time. =) Pointed out by: cem@